1 19 20 package org.netbeans.modules.versioning.system.cvss.ui.actions.log; 21 22 import org.netbeans.modules.versioning.system.cvss.CvsVersioningSystem; 23 import org.netbeans.modules.versioning.system.cvss.ExecutorSupport; 24 import org.netbeans.modules.versioning.system.cvss.ClientRuntime; 25 import org.netbeans.lib.cvsclient.command.GlobalOptions; 26 import org.netbeans.lib.cvsclient.command.Command; 27 import org.netbeans.lib.cvsclient.command.log.LogCommand; 28 import org.netbeans.lib.cvsclient.command.log.LogInformation; 29 import org.netbeans.lib.cvsclient.event.FileInfoEvent; 30 import org.openide.util.NbBundle; 31 import org.openide.ErrorManager; 32 33 import java.util.*; 34 import java.io.IOException ; 35 36 37 43 public class LogExecutor extends ExecutorSupport { 44 45 private final List listeners = new ArrayList(1); 46 47 57 public static LogExecutor [] splitCommand(LogCommand cmd, GlobalOptions options) { 58 Command [] cmds = new org.netbeans.lib.cvsclient.command.Command[0]; 59 if (cmd.getDisplayName() == null) cmd.setDisplayName(NbBundle.getMessage(LogExecutor.class, "MSG_LogExecutor_CmdDisplayName")); 60 try { 61 cmds = prepareBasicCommand(cmd); 62 } catch (IOException e) { 63 ErrorManager.getDefault().notify(e); 64 return null; 65 } 66 LogExecutor [] executors = new LogExecutor[cmds.length]; 67 for (int i = 0; i < cmds.length; i++) { 68 Command command = cmds[i]; 69 executors[i] = new LogExecutor(CvsVersioningSystem.getInstance(), (LogCommand) command, options); 70 } 71 return executors; 72 } 73 74 public LogExecutor(CvsVersioningSystem cvs, LogCommand cmd) { 75 this(cvs, cmd, null); 76 } 77 78 public LogExecutor(CvsVersioningSystem cvs, LogCommand cmd, GlobalOptions options) { 79 super(cvs, cmd, options); 80 } 81 82 protected void commandFinished(ClientRuntime.Result result) { 83 } 84 85 public void fileInfoGenerated(FileInfoEvent e) { 86 super.fileInfoGenerated(e); 87 LogInformation li = (LogInformation) e.getInfoContainer(); 88 List revisions = li.getRevisionList(); 89 Iterator rit = revisions.iterator(); 90 Map messages = new HashMap(revisions.size()); 91 while (rit.hasNext()) { 92 LogInformation.Revision rev = (LogInformation.Revision) rit.next(); 93 String message = rev.getMessage(); 94 String revId = rev.getNumber(); 95 messages.put(revId, message); 96 } 97 Iterator it = listeners.iterator(); 98 while (it.hasNext()) { 99 LogOutputListener listener = (LogOutputListener) it.next(); 100 listener.commitMessages(messages); 101 } 102 } 103 104 public void addLogOutputListener(LogOutputListener listener) { 105 listeners.add(listener); 106 } 107 108 public List getLogEntries() { 109 return toRefresh; 110 } 111 112 protected boolean logCommandOutput() { 113 return false; 114 } 115 } 116 | Popular Tags |