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.ui.tree.comment;
18  
19  import com.atlassian.theplugin.commons.crucible.api.model.GeneralComment;
20  import com.atlassian.theplugin.commons.crucible.api.model.ReviewAdapter;
21  import com.atlassian.theplugin.idea.ui.tree.AtlassianClickAction;
22  import com.atlassian.theplugin.idea.ui.tree.AtlassianTreeNode;
23  
24  
25  public class GeneralCommentTreeNode extends CommentTreeNode {
26  	private GeneralComment comment;
27  
28  	public GeneralCommentTreeNode(ReviewAdapter review, GeneralComment comment, AtlassianClickAction action) {
29  		super(action);
30  		this.review = review;
31  		this.comment = comment;
32  	}
33  
34  	public GeneralCommentTreeNode(final GeneralCommentTreeNode node) {
35  		super(node.getAtlassianClickAction());
36  		this.review = node.review;
37  		this.comment = node.comment;
38  	}
39  
40  	@Override
41  	public GeneralComment getComment() {
42  		return comment;
43  	}
44  
45  	@Override
46  	public AtlassianTreeNode getClone() {
47  		return new GeneralCommentTreeNode(this);
48  	}
49  
50  	@Override
51  	public int compareTo(Object o) {
52  		if (o instanceof GeneralCommentTreeNode) {
53  			GeneralCommentTreeNode gctn = (GeneralCommentTreeNode) o;
54  			return getComment().getCreateDate().compareTo(gctn.getComment().getCreateDate());
55  		}
56  		return super.compareTo(o);
57  	}
58  }