diff --git a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties index 1a696ce18dd1..c43a47a2ca94 100644 --- a/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties +++ b/plugins/hg4idea/resources/org/zmlx/hg4idea/HgVcsMessages.properties @@ -114,4 +114,6 @@ hg4idea.integrate.other.head=Other head: {0} hg4idea.dialog.login.password.required=Login and password required hg4idea.dialog.login.description=Login to {0} -hg4idea.exception.file.not.under.hg=The file {0} is not under Mercurial. \ No newline at end of file +hg4idea.exception.file.not.under.hg=The file {0} is not under Mercurial. + +hg4idea.history.copy.revision.number=Copy Revision Number \ No newline at end of file diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgCopyHistoryRevisionNumberAction.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgCopyHistoryRevisionNumberAction.java new file mode 100644 index 000000000000..ea6d72151918 --- /dev/null +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgCopyHistoryRevisionNumberAction.java @@ -0,0 +1,63 @@ +/* + * 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 org.zmlx.hg4idea; + +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.ide.CopyPasteManager; +import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.vcs.VcsDataKeys; +import com.intellij.openapi.vcs.history.VcsFileRevision; +import com.intellij.util.PlatformIcons; + +import java.awt.datatransfer.StringSelection; + +/** + * @author Nadya Zabrodina + */ +public class HgCopyHistoryRevisionNumberAction extends AnAction implements DumbAware { + + /** + * The constructor + */ + public HgCopyHistoryRevisionNumberAction() { + super(HgVcsMessages.message("hg4idea.history.copy.revision.number"), + HgVcsMessages.message("hg4idea.history.copy.revision.number"), + PlatformIcons.COPY_ICON); + } + + /** + * {@inheritDoc} + */ + @Override + public void actionPerformed(AnActionEvent e) { + VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION); + if (revision != null) { + CopyPasteManager.getInstance().setContents(new StringSelection(revision.getRevisionNumber().asString())); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void update(AnActionEvent e) { + super.update(e); + e.getPresentation().setEnabled((e.getData(VcsDataKeys.VCS_FILE_REVISION) != null)); + } +} + + diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java index c56ebd7fb26a..5c7fc4ed6f4b 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/provider/HgHistoryProvider.java @@ -16,17 +16,19 @@ import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.VcsException; +import com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction; import com.intellij.openapi.vcs.history.*; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.ui.ColumnInfo; import com.intellij.vcsUtil.VcsUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.zmlx.hg4idea.HgCopyHistoryRevisionNumberAction; import org.zmlx.hg4idea.HgFile; import org.zmlx.hg4idea.HgFileRevision; -import org.zmlx.hg4idea.util.HgUtil; import org.zmlx.hg4idea.command.HgLogCommand; import org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand; +import org.zmlx.hg4idea.util.HgUtil; import javax.swing.*; import java.util.ArrayList; @@ -49,7 +51,7 @@ public class HgHistoryProvider implements VcsHistoryProvider { } public AnAction[] getAdditionalActions(Runnable runnable) { - return new AnAction[0]; + return new AnAction[]{ShowAllAffectedGenericAction.getInstance(), new HgCopyHistoryRevisionNumberAction()}; } public boolean isDateOmittable() {