KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > subscriber > ChangeLogDiffNode


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

11 package org.eclipse.team.internal.ccvs.ui.subscriber;
12
13 import java.text.DateFormat JavaDoc;
14
15 import org.eclipse.core.resources.IResource;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.team.internal.ccvs.core.ILogEntry;
18 import org.eclipse.team.internal.ccvs.ui.*;
19 import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
20 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
21 import org.eclipse.team.internal.ui.synchronize.SynchronizeModelElement;
22 import org.eclipse.team.ui.synchronize.ISynchronizeModelElement;
23
24 /**
25  * A model element corresponding to a "commit set". It displays a CVS
26  * log entry using a currently fixed format. A commit doesn't have an
27  * associated resource.
28  *
29  * @since 3.0
30  */

31 public class ChangeLogDiffNode extends SynchronizeModelElement {
32
33     private ILogEntry logEntry;
34
35     public ChangeLogDiffNode(ISynchronizeModelElement parent, ILogEntry logEntry) {
36         super(parent);
37         this.logEntry = logEntry;
38     }
39
40     public ILogEntry getComment() {
41         return logEntry;
42     }
43     
44     public boolean equals(Object JavaDoc obj) {
45         if(obj == this) return true;
46         if(! (obj instanceof ChangeLogDiffNode)) return false;
47         ChangeLogDiffNode other = (ChangeLogDiffNode)obj;
48         ILogEntry otherLog = other.getComment();
49         ILogEntry thisLog = getComment();
50         return thisLog.getComment().equals(otherLog.getComment()) && thisLog.getAuthor().equals(otherLog.getAuthor());
51     }
52
53     /* (non-Javadoc)
54      * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
55      */

56     public ImageDescriptor getImageDescriptor(Object JavaDoc object) {
57         return CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_CHANGELOG);
58     }
59
60     /* (non-Javadoc)
61      * @see org.eclipse.compare.structuremergeviewer.DiffNode#getName()
62      */

63     public String JavaDoc getName() {
64         String JavaDoc date = DateFormat.getDateTimeInstance().format(logEntry.getDate());
65         String JavaDoc comment = HistoryView.flattenText(logEntry.getComment());
66         return "["+logEntry.getAuthor()+ "] (" + date +") " + comment; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
67
}
68     
69     /* (non-Javadoc)
70      * @see org.eclipse.team.ui.synchronize.SyncInfoModelElement#toString()
71      */

72     public String JavaDoc toString() {
73         return getName();
74     }
75
76     /* (non-Javadoc)
77      * @see org.eclipse.team.ui.synchronize.viewers.SynchronizeModelElement#getResource()
78      */

79     public IResource getResource() {
80         return null;
81     }
82 }
83
Popular Tags