2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package com
.intellij
.openapi
.vcs
.changes
;
18 import com
.intellij
.ide
.SelectInContext
;
19 import com
.intellij
.ide
.SelectInTarget
;
20 import com
.intellij
.openapi
.project
.DumbAware
;
21 import com
.intellij
.openapi
.project
.Project
;
22 import com
.intellij
.openapi
.vcs
.FileStatus
;
23 import com
.intellij
.openapi
.vcs
.FileStatusManager
;
24 import com
.intellij
.openapi
.vcs
.ProjectLevelVcsManager
;
25 import com
.intellij
.openapi
.vcs
.VcsBundle
;
26 import com
.intellij
.openapi
.vcs
.changes
.ui
.ChangesViewContentManager
;
27 import com
.intellij
.openapi
.vfs
.VirtualFile
;
28 import com
.intellij
.openapi
.wm
.ToolWindowManager
;
29 import org
.jetbrains
.annotations
.Nullable
;
34 public class SelectInChangesViewTarget
implements SelectInTarget
, DumbAware
{
35 private final Project myProject
;
37 public SelectInChangesViewTarget(final Project project
) {
41 public String
toString() {
42 return VcsBundle
.message("changes.toolwindow.name");
45 public boolean canSelect(final SelectInContext context
) {
46 final VirtualFile file
= context
.getVirtualFile();
47 FileStatus fileStatus
= FileStatusManager
.getInstance(myProject
).getStatus(file
);
48 return ProjectLevelVcsManager
.getInstance(myProject
).getAllActiveVcss().length
!= 0 &&
49 !fileStatus
.equals(FileStatus
.NOT_CHANGED
);
52 public void selectIn(final SelectInContext context
, final boolean requestFocus
) {
53 final VirtualFile file
= context
.getVirtualFile();
54 Runnable runnable
= new Runnable() {
56 ChangesViewContentManager
.getInstance(myProject
).selectContent("Local");
57 ChangesViewManager
.getInstance(myProject
).selectFile(file
);
61 ToolWindowManager
.getInstance(myProject
).getToolWindow(ChangesViewContentManager
.TOOLWINDOW_ID
).activate(runnable
);
68 public String
getToolWindowId() {
69 return ChangesViewContentManager
.TOOLWINDOW_ID
;
72 @Nullable public String
getMinorViewId() {
76 public float getWeight() {