diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java new file mode 100644 index 000000000000..d7c3f1464c49 --- /dev/null +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/changes/MarkerVcsContentRevision.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vcs.changes; + +import com.intellij.openapi.vcs.VcsKey; + +/** + * Created with IntelliJ IDEA. + * User: Irina.Chernushina + * Date: 6/14/12 + * Time: 5:13 PM + */ +public interface MarkerVcsContentRevision { + VcsKey getVcsKey(); +} diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java index 4b8a373c4e15..34dceaffd3e7 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnContentRevision.java @@ -20,7 +20,9 @@ import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Throwable2Computable; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vcs.impl.ContentRevisionCache; import com.intellij.openapi.vcs.impl.CurrentRevisionProvider; @@ -39,7 +41,7 @@ import java.io.IOException; /** * @author yole */ -public class SvnContentRevision implements ContentRevision { +public class SvnContentRevision implements ContentRevision, MarkerVcsContentRevision { private final SvnVcs myVcs; protected final FilePath myFile; private final SVNRevision myRevision; @@ -145,4 +147,9 @@ public class SvnContentRevision implements ContentRevision { public String toString() { return myFile.getPath(); } + + @Override + public VcsKey getVcsKey() { + return SvnVcs.getKey(); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java index fdac020cc209..c9b7f6c08c79 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/actions/AbstractShowPropertiesDiffAction.java @@ -31,6 +31,7 @@ import com.intellij.openapi.vcs.VcsDataKeys; import com.intellij.openapi.vcs.changes.Change; import com.intellij.openapi.vcs.changes.ChangesUtil; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vfs.VirtualFile; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -70,11 +71,30 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen public void update(final AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = PlatformDataKeys.PROJECT.getData(dataContext); - final Change[] changes = e.getData(getChangesKey()); final Presentation presentation = e.getPresentation(); - presentation.setVisible(VcsDataKeys.CHANGES.getData(dataContext) != null); - presentation.setEnabled(enabled(project, changes)); + final Change[] data = VcsDataKeys.CHANGES.getData(dataContext); + boolean showAction = checkThatChangesAreUnderSvn(data); + presentation.setVisible(data != null && showAction); + presentation.setEnabled(showAction); + } + + private boolean checkThatChangesAreUnderSvn(Change[] data) { + boolean showAction = false; + if (data != null) { + for (Change change : data) { + final ContentRevision before = change.getBeforeRevision(); + if (before != null) { + showAction = showAction || before instanceof MarkerVcsContentRevision && SvnVcs.getKey().equals(((MarkerVcsContentRevision)before).getVcsKey()); + } + final ContentRevision after = change.getAfterRevision(); + if (after != null) { + showAction = showAction || after instanceof MarkerVcsContentRevision && SvnVcs.getKey().equals(((MarkerVcsContentRevision)after).getVcsKey()); + } + if (showAction) break; + } + } + return showAction; } private boolean enabled(final Project project, final Change[] changes) { @@ -107,7 +127,7 @@ public abstract class AbstractShowPropertiesDiffAction extends AnAction implemen final Project project = PlatformDataKeys.PROJECT.getData(dataContext); final Change[] changes = e.getData(getChangesKey()); - if (! enabled(project, changes)) { + if (! checkThatChangesAreUnderSvn(changes)) { return; } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java index 141858d4d11b..aaa4247e7d56 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnLazyPropertyContentRevision.java @@ -18,11 +18,12 @@ package org.jetbrains.idea.svn.history; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.util.Ref; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import org.jetbrains.annotations.NotNull; import org.jetbrains.idea.svn.SvnBundle; @@ -39,7 +40,7 @@ import org.tmatesoft.svn.core.wc.SVNWCClient; * Date: 2/22/12 * Time: 10:28 AM */ -public class SvnLazyPropertyContentRevision implements ContentRevision { +public class SvnLazyPropertyContentRevision implements ContentRevision, MarkerVcsContentRevision { private final FilePath myPath; private final VcsRevisionNumber myNumber; private final Project myProject; @@ -101,4 +102,9 @@ public class SvnLazyPropertyContentRevision implements ContentRevision { public VcsRevisionNumber getRevisionNumber() { return myNumber; } + + @Override + public VcsKey getVcsKey() { + return SvnVcs.getKey(); + } } diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java index 801f18105b72..836f6b4c83b1 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/history/SvnRepositoryContentRevision.java @@ -30,8 +30,10 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Throwable2Computable; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.VcsKey; import com.intellij.openapi.vcs.actions.VcsContextFactory; import com.intellij.openapi.vcs.changes.ContentRevision; +import com.intellij.openapi.vcs.changes.MarkerVcsContentRevision; import com.intellij.openapi.vcs.history.VcsRevisionNumber; import com.intellij.openapi.vcs.impl.ContentRevisionCache; import org.jetbrains.annotations.NotNull; @@ -47,7 +49,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -public class SvnRepositoryContentRevision implements ContentRevision { +public class SvnRepositoryContentRevision implements ContentRevision, MarkerVcsContentRevision { private final String myRepositoryRoot; private final SvnVcs myVcs; private final String myPath; @@ -180,4 +182,9 @@ public class SvnRepositoryContentRevision implements ContentRevision { public String getPath() { return myPath; } + + @Override + public VcsKey getVcsKey() { + return SvnVcs.getKey(); + } }