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.action.crucible;
18  
19  
20  import com.atlassian.theplugin.idea.CrucibleReviewWindow;
21  import com.atlassian.theplugin.idea.IdeaHelper;
22  import com.atlassian.theplugin.idea.VcsIdeaHelper;
23  import com.atlassian.theplugin.idea.crucible.CrucibleTableToolWindowPanel;
24  import com.atlassian.theplugin.idea.crucible.ReviewData;
25  import com.atlassian.theplugin.idea.crucible.CrucibleConstants;
26  import com.atlassian.theplugin.idea.crucible.comments.CrucibleReviewActionListener;
27  import com.atlassian.theplugin.idea.crucible.events.ShowReviewEvent;
28  import com.intellij.openapi.actionSystem.AnActionEvent;
29  import com.intellij.openapi.actionSystem.DataKeys;
30  import com.intellij.openapi.project.Project;
31  import com.intellij.openapi.ui.Messages;
32  
33  import javax.swing.*;
34  
35  public class GetCommentsAction extends TableSelectedAction {
36  
37  	public void actionPerformed(final AnActionEvent e) {
38  		Project project = IdeaHelper.getCurrentProject(e);
39  
40  
41  		 if (project != null && e.getPlace() != null
42                  && e.getPlace().equals(CrucibleTableToolWindowPanel.PLACE_PREFIX + project.getName())) {
43              if (!VcsIdeaHelper.isUnderVcsControl(e)) {
44  				Messages.showInfoMessage(project, CrucibleConstants.CRUCIBLE_MESSAGE_NOT_UNDER_VCS,
45  							CrucibleConstants.CRUCIBLE_TITLE_NOT_UNDER_VCS);
46  
47  			} else {
48  				CrucibleReviewWindow.getInstance(project);
49  				super.actionPerformed(e);
50  			}
51          }
52  
53  	}
54  
55  	protected void itemSelected(final Project project, Object row) {
56  
57  		IdeaHelper.getReviewActionEventBroker(project).trigger(new ShowReviewEvent(
58  				CrucibleReviewActionListener.ANONYMOUS, (ReviewData) row));
59  
60  	}	
61  }