001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/
004    
005    package graphlab.plugins.automaticupdator.net.interdirected.autoupdate;
006    
007    import org.tmatesoft.svn.core.SVNCancelException;
008    import org.tmatesoft.svn.core.wc.ISVNEventHandler;
009    import org.tmatesoft.svn.core.wc.SVNEvent;
010    import org.tmatesoft.svn.core.wc.SVNEventAction;
011    
012    public class UpdateEventHandler implements ISVNEventHandler {
013    
014        private GuiStatusScreen gss = null;
015    
016        public void setGuiStatusScreen(GuiStatusScreen GuiScreen) {
017            gss = GuiScreen;
018        }
019    
020        public void handleEvent(SVNEvent event, double progress) {
021            SVNEventAction action = event.getAction();
022            String pathChangeType = "";
023            if (action == SVNEventAction.UPDATE_ADD) {
024                pathChangeType = "A";
025            } else if (action == SVNEventAction.UPDATE_DELETE) {
026                pathChangeType = "D";
027            } else if (action == SVNEventAction.UPDATE_UPDATE) {
028                pathChangeType = "C";
029            }
030            if (gss != null) {
031                if (pathChangeType.length() > 0) gss.appendText(pathChangeType + ": " + event.getPath());
032            } else {
033                if (pathChangeType.length() > 0) System.out.println(pathChangeType + ": " + event.getPath());
034            }
035        }
036    
037        public void checkCancelled() throws SVNCancelException {
038        }
039    }