View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package com.atlassian.theplugin.idea.crucible;
18  
19  
20  import com.atlassian.theplugin.commons.crucible.api.model.GeneralComment;
21  
22  import javax.swing.tree.DefaultMutableTreeNode;
23  
24  /**
25   * Created by IntelliJ IDEA.
26   * User: pmaruszak
27   * Date: Jun 10, 2008
28   * Time: 4:26:43 PM
29   * To change this template use File | Settings | File Templates.
30   */
31  public class CommentNode  extends DefaultMutableTreeNode {
32  	private GeneralComment generalComment;
33      // TODO why its 10???                                    
34      private static final int BEGIN_INDEX = 10;
35  
36      public CommentNode(GeneralComment aGeneralComment) {
37  		this.generalComment = aGeneralComment;
38  	}
39  
40     // public abstract ServerType getServerType();
41  
42  	public GeneralComment getGeneralComment() {
43  		return generalComment;
44  	}
45  
46  	public void setGeneralComment(GeneralComment generalComment) {
47  		this.generalComment = generalComment;
48  	}
49  
50  	public String toString() {
51  		return generalComment.getMessage().substring(BEGIN_INDEX) + "(" + generalComment.getAuthor() + ")";
52  	}
53  
54  	public boolean equals(Object o) {
55  		if (this == o) {
56  			return true;
57  		}
58  		if (o == null || getClass() != o.getClass()) {
59  			return false;
60  		}
61  
62  		CommentNode that = (CommentNode) o;
63  
64  		if (!generalComment.equals(that.generalComment)) {
65  			return false;
66  		}
67  
68  		return true;
69  	}
70  
71  	public int hashCode() {
72  		return generalComment.hashCode();
73  	}
74  }
75