Package de.fu_berlin.inf.dpp.activities.business

Examples of de.fu_berlin.inf.dpp.activities.business.ProgressActivity


            int totalWorked = -1;

            public void beginTask(String name, int totalWorked) {
                this.totalWorked = totalWorked;
                sarosSession.sendActivity(recipients, new ProgressActivity(
                    localUser, progressID, 0, totalWorked, name,
                    ProgressAction.UPDATE));
            }

            public void done() {
                sarosSession.sendActivity(recipients, new ProgressActivity(
                    localUser, progressID, 0, 0, null, ProgressAction.DONE));
            }

            public void internalWorked(double work) {
                // do nothing
            }

            public boolean isCanceled() {
                // It would be cool to support communicating cancellation
                // to the originator
                return false;
            }

            public void setCanceled(boolean value) {
                throw new UnsupportedOperationException();
            }

            public void setTaskName(String name) {
                sarosSession.sendActivity(recipients, new ProgressActivity(
                    localUser, progressID, worked, totalWorked, name,
                    ProgressAction.UPDATE));
            }

            public void subTask(String name) {
                sarosSession.sendActivity(recipients, new ProgressActivity(
                    localUser, progressID, worked, totalWorked, name,
                    ProgressAction.UPDATE));
            }

            public void worked(int work) {
                worked += work;
                if (worked > totalWorked)
                    log.warn(
                        MessageFormat
                            .format(
                                "Worked ({0})is greater than totalWork ({1}). Forgot to call beginTask?",
                                worked, totalWorked), new StackTrace());
                sarosSession.sendActivity(recipients, new ProgressActivity(
                    localUser, progressID, worked, totalWorked, null,
                    ProgressAction.UPDATE));
            }
        };
    }
View Full Code Here


        public synchronized void close() {
            if (activities == null)
                return;

            receive(new ProgressActivity(source, progressID, 0, 0, null,
                ProgressAction.DONE));
        }
View Full Code Here

        protected void mainloop(SubMonitor subMonitor) {
            int worked = 0;
            boolean firstTime = true;

            while (true) {
                ProgressActivity nextActivity;
                try {
                    nextActivity = activities.take();
                } catch (InterruptedException e) {
                    return;
                }

                switch (nextActivity.getAction()) {
                case UPDATE:
                    String taskName = nextActivity.getTaskName();
                    if (firstTime) {
                        subMonitor.beginTask(taskName,
                            nextActivity.getWorkTotal());
                        firstTime = false;
                    } else {
                        if (taskName != null)
                            subMonitor.subTask(taskName);

                        int newWorked = nextActivity.getWorkCurrent();
                        if (newWorked > worked) {
                            subMonitor.worked(newWorked - worked);
                            worked = newWorked;
                        }
                    }
View Full Code Here

        User user = sarosSession.getUser(source);
        if (user == null)
            throw new IllegalArgumentException("Buddy is not in shared project");

        return new ProgressActivity(user, progressID, workCurrent, workTotal,
            taskName, action);
    }
View Full Code Here

TOP

Related Classes of de.fu_berlin.inf.dpp.activities.business.ProgressActivity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.