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  import com.atlassian.theplugin.commons.crucible.CrucibleServerFacadeImpl;
20  import com.atlassian.theplugin.idea.crucible.CrucibleRevisionAddWorker;
21  import com.intellij.openapi.actionSystem.AnActionEvent;
22  import com.intellij.openapi.actionSystem.DataKeys;
23  import com.intellij.openapi.application.ApplicationManager;
24  import com.intellij.openapi.application.ModalityState;
25  import com.intellij.openapi.vcs.changes.ChangeList;
26  import com.intellij.openapi.vcs.changes.Change;
27  import com.intellij.openapi.project.Project;
28  
29  
30  public class ViewFisheyeChangesetAction extends Crucible16RepositoryAction {
31      public void actionPerformed(AnActionEvent event) {
32          final ChangeList[] changes = DataKeys.CHANGE_LISTS.getData(event.getDataContext());
33  		final Project project = event.getData(DataKeys.PROJECT);
34  
35  		if (changes.length == 1) {
36              String rev = "";
37              for (Change change : changes[0].getChanges()) {
38                  rev = change.getAfterRevision().getRevisionNumber().asString();
39                  break;
40              }
41              final String finalRev = rev;
42              new Thread(new Runnable() {
43                  public void run() {
44                      ApplicationManager.getApplication().invokeAndWait(
45                              new CrucibleRevisionAddWorker(project, CrucibleServerFacadeImpl.getInstance(), finalRev),
46                              ModalityState.defaultModalityState());
47                  }
48              }).start();
49          }
50      }
51  }
52