IDEA-81540 Mercurial (hg) integration should allow to copy revision number to clipboard

This commit is contained in:
Nadya.Zabrodina
2012-10-09 18:22:32 +04:00
parent d4baee7f65
commit 44e992b8ad
3 changed files with 70 additions and 3 deletions
@@ -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.
hg4idea.exception.file.not.under.hg=The file {0} is not under Mercurial.
hg4idea.history.copy.revision.number=Copy Revision Number
@@ -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));
}
}
@@ -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() {