KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > client > listeners > EditorsListener


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * CSC - Intial implementation
10  * IBM Corporation - ongoing maintenance
11  *******************************************************************************/

12 package org.eclipse.team.internal.ccvs.core.client.listeners;
13
14 import java.util.LinkedList JavaDoc;
15 import java.util.List JavaDoc;
16 import java.util.StringTokenizer JavaDoc;
17
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.core.runtime.IStatus;
20 import org.eclipse.team.internal.ccvs.core.EditorsInfo;
21 import org.eclipse.team.internal.ccvs.core.ICVSFolder;
22 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
23 import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;
24
25
26 /**
27  *
28  *
29  * Listener for the Editors command
30  *
31  * @author <a HREF="mailto:kohlwes@gmx.net">Gregor Kohlwes</a>
32  *
33  */

34 public class EditorsListener extends CommandOutputListener {
35     /**
36      * List to store the EditorsInfos
37      */

38     private List JavaDoc infos = new LinkedList JavaDoc();
39     
40     /**
41      * Name of the current file
42      */

43     private String JavaDoc fileName;
44
45     /**
46      * Constructor EditorsListener.
47      */

48     public EditorsListener() {
49     }
50
51     /**
52      * @see org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener#messageLine(java.lang.String, org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation, org.eclipse.team.internal.ccvs.core.ICVSFolder, org.eclipse.core.runtime.IProgressMonitor)
53      */

54     public IStatus messageLine(
55         String JavaDoc line,
56         ICVSRepositoryLocation location,
57         ICVSFolder commandRoot,
58         IProgressMonitor monitor) {
59
60         // If there is a file with multiple editors
61
// then cvs will write the filename only
62
// in the first line and the following
63
// line will start with a Tab
64
if (line.startsWith("\t")) { //$NON-NLS-1$
65
line = fileName + line;
66         }
67         EditorsInfo info = new EditorsInfo();
68         StringTokenizer JavaDoc tokenizer = new StringTokenizer JavaDoc(line,"\t"); //$NON-NLS-1$
69
int i = 0;
70         while(tokenizer.hasMoreTokens()) {
71             String JavaDoc token = tokenizer.nextToken();
72             switch (i) {
73                 case 0:
74                     info.setFileName(token);
75                     fileName = token;
76                     break;
77                 case 1:
78                     info.setUserName(token);
79                     break;
80                 case 2:
81                     info.setDateString(token);
82                     break;
83                 case 3:
84                     info.setComputerName(token);
85                     break;
86                 default :
87                     break;
88             }
89             i++;
90         }
91         
92         infos.add(info);
93         return OK;
94
95     }
96     /**
97      * Method getEditorsInfos.
98      * @return IEditorsInfo[]
99      */

100     public EditorsInfo[] getEditorsInfos() {
101         return (EditorsInfo[]) infos.toArray(new EditorsInfo[infos.size()]);
102     }
103
104 }
105
Popular Tags