Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 73a6ebaa0e41962b7d2d8b2c4c5f5b2e2c2b3484 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     CSC - Intial implementation
 *     IBM Corporation - ongoing maintenance
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client.listeners;

import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.EditorsInfo;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.client.CommandOutputListener;


/**
 * 
 *
 * Listener for the Editors command
 * 
 * @author <a href="mailto:kohlwes@gmx.net">Gregor Kohlwes</a>
 * 
 */
public class EditorsListener extends CommandOutputListener {
	/**
	 *  List to store the EditorsInfos
	 */
	private List infos = new LinkedList();
	
	/**
	 *  Name of the current file 
	 */
	private String fileName;

	/**
	 * Constructor EditorsListener.
	 */
	public EditorsListener() {
	}

	@Override
	public IStatus messageLine(
		String line,
		ICVSRepositoryLocation location,
		ICVSFolder commandRoot,
		IProgressMonitor monitor) {

		// If there is a file with multiple editors
		// then cvs will write the filename only 
		// in the first line and the following
		// line will start with a Tab
		if (line.startsWith("\t")) { //$NON-NLS-1$
			line = fileName + line;
		}
		EditorsInfo info = new EditorsInfo();
		StringTokenizer tokenizer = new StringTokenizer(line,"\t"); //$NON-NLS-1$
		int i = 0;
		while(tokenizer.hasMoreTokens()) {
			String token = tokenizer.nextToken();
			switch (i) {
				case 0:
					info.setFileName(token);
					fileName = token;
					break;
				case 1:
					info.setUserName(token);
					break;
				case 2:
					info.setDateString(token);
					break;
				case 3:
					info.setComputerName(token);
					break;
				default :
					break;
			}
			i++;			
		}
		
		infos.add(info);
		return OK;

	}
	/**
	 * Method getEditorsInfos.
	 * @return IEditorsInfo[]
	 */
	public EditorsInfo[] getEditorsInfos() {
		return (EditorsInfo[]) infos.toArray(new EditorsInfo[infos.size()]);
	}

}

Back to the top