mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* 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.
|
||||
@@ -40,6 +40,7 @@ public class NonProjectFilesScope extends NamedScope {
|
||||
super(NAME, new AbstractPackageSet("NonProject") {
|
||||
public boolean contains(VirtualFile file, NamedScopesHolder holder) {
|
||||
if (file == null) return true;
|
||||
if (file.getFileSystem() != LocalFileSystem.getInstance()) return true;
|
||||
if (isInsideProjectContent(holder.getProject(), file)) return false;
|
||||
return !ProjectScope.getProjectScope(holder.getProject()).contains(file);
|
||||
}
|
||||
|
||||
+1
@@ -346,6 +346,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
myFontSizeSlider.setSnapToTicks(true);
|
||||
UIUtil.setSliderIsFilled(myFontSizeSlider, true);
|
||||
result.add(myFontSizeSlider);
|
||||
result.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor(), 1));
|
||||
|
||||
myFontSizeSlider.addChangeListener(new ChangeListener() {
|
||||
@Override
|
||||
|
||||
+4
-2
@@ -182,12 +182,14 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
createToolWindow(element, original);
|
||||
return;
|
||||
}
|
||||
|
||||
final Content content = myToolWindow.getContentManager().getSelectedContent();
|
||||
if (content == null) {
|
||||
if (content == null || !myToolWindow.isVisible()) {
|
||||
restorePopupBehavior();
|
||||
createToolWindow(element, original);
|
||||
return;
|
||||
}
|
||||
|
||||
fetchDocInfo(getDefaultCollector(element, original), (DocumentationComponent)content.getComponent(), true);
|
||||
}
|
||||
|
||||
@@ -212,7 +214,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
}
|
||||
|
||||
public void showJavaDocInfo(final Editor editor, @Nullable final PsiFile file, boolean requestFocus) {
|
||||
showJavaDocInfo(editor, file, requestFocus, false);
|
||||
showJavaDocInfo(editor, file, requestFocus, true);
|
||||
}
|
||||
|
||||
private void showJavaDocInfo(final Editor editor, @Nullable final PsiFile file, boolean requestFocus, final boolean autoupdate) {
|
||||
|
||||
-1
@@ -62,7 +62,6 @@ public class ConfigurationSettingsEditorWrapper extends SettingsEditor<RunnerAnd
|
||||
final RunConfiguration runConfiguration = settings.getConfiguration();
|
||||
myBeforeRunStepsPanel.doReset(settings);
|
||||
myBeforeLaunchContainer.setVisible(!(runConfiguration instanceof UnknownRunConfiguration));
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+6
-1
@@ -251,7 +251,12 @@ public final class SingleConfigurationConfigurable<Config extends RunConfigurati
|
||||
updateWarning();
|
||||
}
|
||||
});
|
||||
|
||||
myCbStoreProjectConfiguration.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
settingAnchor();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,10 @@ import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The DialogBuilder is a simpler alternative to {@link DialogWrapper}.
|
||||
* There is no need to create a subclass (which is needed in the DialogWrapper), which can be nice for simple dialogs.
|
||||
*/
|
||||
public class DialogBuilder implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.ui.DialogBuilder");
|
||||
|
||||
@@ -68,7 +72,8 @@ public class DialogBuilder implements Disposable {
|
||||
}
|
||||
|
||||
private MyDialogWrapper showImpl(boolean isModal) {
|
||||
LOG.assertTrue(myTitle != null && myTitle.trim().length() != 0, String.valueOf(myTitle));
|
||||
LOG.assertTrue(myTitle != null && myTitle.trim().length() != 0,
|
||||
String.format("Dialog title shouldn't be empty or null: [%s]", myTitle));
|
||||
myDialogWrapper.setTitle(myTitle);
|
||||
myDialogWrapper.init();
|
||||
myDialogWrapper.setModal(isModal);
|
||||
@@ -213,6 +218,10 @@ public class DialogBuilder implements Disposable {
|
||||
public static class CloseDialogAction extends DialogActionDescriptor {
|
||||
private final int myExitCode;
|
||||
|
||||
public CloseDialogAction() {
|
||||
this(CommonBundle.getCloseButtonText(), -1, DialogWrapper.CLOSE_EXIT_CODE);
|
||||
}
|
||||
|
||||
public CloseDialogAction(String name, int mnemonicChar, int exitCode) {
|
||||
super(name, mnemonicChar);
|
||||
myExitCode = exitCode;
|
||||
|
||||
@@ -74,6 +74,10 @@ public abstract class DialogWrapper {
|
||||
* The default exit code for "Cancel" action.
|
||||
*/
|
||||
public static final int CANCEL_EXIT_CODE = 1;
|
||||
/**
|
||||
* The default exit code for "Close" action. Equal to cancel.
|
||||
*/
|
||||
public static final int CLOSE_EXIT_CODE = CANCEL_EXIT_CODE;
|
||||
/**
|
||||
* If you use your custom exit codes you have have to start them with
|
||||
* this constant.
|
||||
|
||||
@@ -64,9 +64,11 @@ public abstract class ColoredTreeCellRenderer extends SimpleColoredComponent imp
|
||||
if (UIUtil.isFullRowSelectionLAF()) {
|
||||
setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
|
||||
}
|
||||
else if (/*UIUtil.isUnderAquaBasedLookAndFeel() && */tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
|
||||
else if (tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
|
||||
setPaintFocusBorder(false);
|
||||
//setBackground(selected ? UIUtil.getTreeSelectionBackground() : null);
|
||||
if (selected) {
|
||||
setBackground(hasFocus ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeUnfocusedSelectionBackground());
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (selected) {
|
||||
|
||||
@@ -4,13 +4,14 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightTestFixture;
|
||||
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
/**
|
||||
* User: Andrey.Vokin
|
||||
* Date: 7/23/12
|
||||
*/
|
||||
public class CodeInsightTestCase extends UsefulTestCase {
|
||||
public class CodeInsightTestCase extends LightPlatformCodeInsightFixtureTestCase {
|
||||
@NonNls protected static final String CARET_STR = "<caret>";
|
||||
|
||||
protected CodeInsightTestFixture myFixture;
|
||||
|
||||
@@ -34,8 +34,9 @@ public class ColorUtil {
|
||||
}
|
||||
|
||||
public static Color softer(@NotNull Color color) {
|
||||
if (color.getBlue() > 220 && color.getRed() > 220 && color.getGreen() > 220) return color;
|
||||
final float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
|
||||
return Color.getHSBColor(hsb[0], 0.4f *hsb[1], hsb[2]);
|
||||
return Color.getHSBColor(hsb[0], 0.6f *hsb[1], hsb[2]);
|
||||
}
|
||||
|
||||
private static int shift(int colorComponent, double d) {
|
||||
|
||||
@@ -947,7 +947,7 @@ public class UIUtil {
|
||||
}
|
||||
|
||||
public static boolean isFullRowSelectionLAF() {
|
||||
return isUnderNimbusLookAndFeel() || isUnderQuaquaLookAndFeel() || isUnderDarcula();
|
||||
return isUnderNimbusLookAndFeel() || isUnderQuaquaLookAndFeel();
|
||||
}
|
||||
|
||||
public static boolean isUnderNativeMacLookAndFeel() {
|
||||
|
||||
@@ -139,7 +139,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
}
|
||||
};
|
||||
|
||||
private final DualViewColumnInfo REVISION =
|
||||
private final VcsColumnInfo<VcsRevisionNumber> REVISION =
|
||||
new VcsColumnInfo<VcsRevisionNumber>(VcsBundle.message("column.name.revision.version")) {
|
||||
protected VcsRevisionNumber getDataOf(VcsFileRevision object) {
|
||||
return object.getRevisionNumber();
|
||||
@@ -162,7 +162,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
|
||||
};
|
||||
|
||||
private final DualViewColumnInfo DATE = new VcsColumnInfo<String>(VcsBundle.message("column.name.revision.date")) {
|
||||
private final VcsColumnInfo<String> DATE = new VcsColumnInfo<String>(VcsBundle.message("column.name.revision.date")) {
|
||||
protected String getDataOf(VcsFileRevision object) {
|
||||
Date date = object.getRevisionDate();
|
||||
if (date == null) return "";
|
||||
@@ -216,7 +216,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
|
||||
private static final TableCellRenderer AUTHOR_RENDERER = new AuthorCellRenderer();
|
||||
|
||||
private final DualViewColumnInfo AUTHOR = new VcsColumnInfo<String>(VcsBundle.message("column.name.revision.list.author")) {
|
||||
private final VcsColumnInfo<String> AUTHOR = new VcsColumnInfo<String>(VcsBundle.message("column.name.revision.list.author")) {
|
||||
protected String getDataOf(VcsFileRevision object) {
|
||||
VcsFileRevision rev = object;
|
||||
if (object instanceof TreeNodeOnVcsRevision) {
|
||||
@@ -540,20 +540,50 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
refreshRevisionsOrder();
|
||||
HistoryAsTreeProvider treeHistoryProvider = session.getHistoryAsTreeProvider();
|
||||
|
||||
List<VcsFileRevision> revisionList = myHistorySession.getRevisionList();
|
||||
updateMaxStringValues(revisionList);
|
||||
if (treeHistoryProvider != null) {
|
||||
myDualView.setRoot(new TreeNodeOnVcsRevision(null,
|
||||
treeHistoryProvider.createTreeOn(myHistorySession.getRevisionList())), myTargetSelection);
|
||||
treeHistoryProvider.createTreeOn(revisionList)), myTargetSelection);
|
||||
}
|
||||
else {
|
||||
myDualView.setRoot(new TreeNodeOnVcsRevision(null,
|
||||
wrapWithTreeElements(myHistorySession.getRevisionList())), myTargetSelection);
|
||||
wrapWithTreeElements(revisionList)), myTargetSelection);
|
||||
}
|
||||
|
||||
updateMaxStringValues(revisionList);
|
||||
myDualView.getFlatView().updateColumnSizes();
|
||||
myDualView.expandAll();
|
||||
myDualView.repaint();
|
||||
}
|
||||
|
||||
private void updateMaxStringValues(@NotNull List<VcsFileRevision> list) {
|
||||
int maxAuthorWidth = getStringWidth(AUTHOR.getMaxStringValue());
|
||||
int maxRevisionWidth = getStringWidth(REVISION.getMaxStringValue());
|
||||
int maxDateWidth = getStringWidth(DATE.getMaxStringValue());
|
||||
for (VcsFileRevision revision : list) {
|
||||
int authorWidth = getStringWidth(revision.getAuthor());
|
||||
int revWidth = getStringWidth(REVISION.valueOf(revision));
|
||||
int dateWidth = getStringWidth(DATE.getDataOf(revision));
|
||||
if (authorWidth > maxAuthorWidth) {
|
||||
AUTHOR.setMaxStringValue(revision.getAuthor());
|
||||
}
|
||||
if (revWidth > maxRevisionWidth) {
|
||||
REVISION.setMaxStringValue(REVISION.valueOf(revision));
|
||||
}
|
||||
if (dateWidth > maxDateWidth) {
|
||||
DATE.setMaxStringValue(DATE.getDataOf(revision));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getStringWidth(@Nullable String string) {
|
||||
if (string == null) {
|
||||
return 0;
|
||||
}
|
||||
return myDualView.getFontMetrics(myDualView.getFont()).stringWidth(string);
|
||||
}
|
||||
|
||||
protected void addActionsTo(DefaultActionGroup group) {
|
||||
addToGroup(false, group);
|
||||
}
|
||||
@@ -875,11 +905,9 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
if (selection.size() != 1) return;
|
||||
if (ChangeListManager.getInstance(myVcs.getProject()).isFreezedWithNotification(null)) return;
|
||||
final VcsRevisionNumber currentRevisionNumber = myHistorySession.getCurrentRevisionNumber();
|
||||
if (currentRevisionNumber != null) {
|
||||
VcsHistoryUtil.showDifferencesInBackground(myVcs.getProject(), myFilePath,
|
||||
getFirstSelectedRevision(),
|
||||
new CurrentRevision(myFilePath.getVirtualFile(), currentRevisionNumber),
|
||||
true);
|
||||
VcsFileRevision selectedRevision = getFirstSelectedRevision();
|
||||
if (currentRevisionNumber != null && selectedRevision != null) {
|
||||
myDiffHandler.showDiff(myFilePath, selectedRevision, new CurrentRevision(myFilePath.getVirtualFile(), currentRevisionNumber));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,9 +944,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
if (!super.isEnabled()) return false;
|
||||
if (!myHistorySession.isContentAvailable(getFirstSelectedRevision())) return false;
|
||||
return true;
|
||||
return super.isEnabled() && myHistorySession.isContentAvailable(getFirstSelectedRevision()) && !myFilePath.isDirectory();
|
||||
}
|
||||
|
||||
protected void executeAction(AnActionEvent e) {
|
||||
@@ -1417,8 +1443,13 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
}
|
||||
}
|
||||
|
||||
abstract static class VcsColumnInfo<T extends Comparable> extends DualViewColumnInfo<VcsFileRevision, String>
|
||||
implements Comparator<VcsFileRevision> {
|
||||
private abstract static class VcsColumnInfo<T extends Comparable>
|
||||
extends DualViewColumnInfo<VcsFileRevision, String>
|
||||
implements Comparator<VcsFileRevision>
|
||||
{
|
||||
|
||||
@Nullable private String myMaxStringValue;
|
||||
|
||||
public VcsColumnInfo(String name) {
|
||||
super(name);
|
||||
}
|
||||
@@ -1453,6 +1484,16 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getMaxStringValue() {
|
||||
return myMaxStringValue;
|
||||
}
|
||||
|
||||
public void setMaxStringValue(@Nullable String maxStringValue) {
|
||||
myMaxStringValue = maxStringValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MyColumnWrapper<T> extends DualViewColumnInfo<TreeNodeOnVcsRevision, Object> {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
@@ -213,9 +214,10 @@ public class VcsHistoryUtil {
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
VcsFileRevision left = revision1;
|
||||
VcsFileRevision right = revision2;
|
||||
if (findOlderNewer && compare(revision1, revision2) > 0) {
|
||||
left = revision2;
|
||||
right = revision1;
|
||||
if (findOlderNewer) {
|
||||
Pair<VcsFileRevision, VcsFileRevision> pair = sortRevisions(revision1, revision2);
|
||||
left = pair.first;
|
||||
right = pair.second;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -244,4 +246,19 @@ public class VcsHistoryUtil {
|
||||
}.queue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares the given revisions and returns a pair of them, where the first one is older, and second is newer.
|
||||
*/
|
||||
@NotNull
|
||||
public static Pair<VcsFileRevision, VcsFileRevision> sortRevisions(@NotNull VcsFileRevision revision1,
|
||||
@NotNull VcsFileRevision revision2) {
|
||||
VcsFileRevision left = revision1;
|
||||
VcsFileRevision right = revision2;
|
||||
if (compare(revision1, revision2) > 0) {
|
||||
left = revision2;
|
||||
right = revision1;
|
||||
}
|
||||
return Pair.create(left, right);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ public final class GitBranchOperationsProcessor {
|
||||
@NotNull
|
||||
private static Collection<Change> loadTotalDiff(@NotNull GitRepository repository, @NotNull String branchName) {
|
||||
try {
|
||||
return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), null, branchName, null);
|
||||
return GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), "HEAD", branchName);
|
||||
}
|
||||
catch (VcsException e) {
|
||||
// we treat it as critical and report an error
|
||||
|
||||
@@ -413,13 +413,22 @@ public class GitChangeUtils {
|
||||
|
||||
@NotNull
|
||||
public static Collection<Change> getDiff(@NotNull Project project, @NotNull VirtualFile root,
|
||||
@Nullable String firstRevision, @NotNull String nextRevision,
|
||||
@Nullable Collection<FilePath> dirtyPaths) throws VcsException {
|
||||
@NotNull String oldRevision, @Nullable String newRevision) throws VcsException {
|
||||
String range;
|
||||
GitRevisionNumber newRev;
|
||||
if (newRevision == null) {
|
||||
// it is current revision
|
||||
range = oldRevision;
|
||||
newRev = null;
|
||||
}
|
||||
else {
|
||||
range = oldRevision + ".." + newRevision;
|
||||
newRev = loadRevision(project, root, newRevision);
|
||||
}
|
||||
String output = getDiffOutput(project, root, range, null);
|
||||
|
||||
Collection<Change> changes = new ArrayList<Change>();
|
||||
String range = firstRevision == null ? nextRevision : firstRevision + ".." + nextRevision;
|
||||
String output = getDiffOutput(project, root, range, dirtyPaths);
|
||||
GitRevisionNumber thisRevision = firstRevision == null ? null : loadRevision(project, root, firstRevision);
|
||||
parseChanges(project, root, thisRevision, loadRevision(project, root, nextRevision), output, changes, Collections.<String>emptySet());
|
||||
parseChanges(project, root, newRev, loadRevision(project, root, oldRevision), output, changes, Collections.<String>emptySet());
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,12 +22,17 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogBuilder;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesBrowser;
|
||||
import com.intellij.openapi.vcs.history.CurrentRevision;
|
||||
import com.intellij.openapi.vcs.history.DiffFromHistoryHandler;
|
||||
import com.intellij.openapi.vcs.history.VcsFileRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsHistoryUtil;
|
||||
@@ -35,14 +40,17 @@ import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Consumer;
|
||||
import git4idea.GitFileRevision;
|
||||
import git4idea.GitRevisionNumber;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.changes.GitChangeUtils;
|
||||
import git4idea.commands.Git;
|
||||
import git4idea.commands.GitCommandResult;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
@@ -92,34 +100,132 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler {
|
||||
|
||||
private void doShowDiff(@NotNull FilePath filePath, @NotNull VcsFileRevision revision1, @NotNull VcsFileRevision revision2,
|
||||
boolean autoSort) {
|
||||
VcsHistoryUtil.showDifferencesInBackground(myProject, filePath, revision1, revision2, autoSort);
|
||||
if (!filePath.isDirectory()) {
|
||||
VcsHistoryUtil.showDifferencesInBackground(myProject, filePath, revision1, revision2, autoSort);
|
||||
}
|
||||
else if (revision2 instanceof CurrentRevision) {
|
||||
GitFileRevision left = (GitFileRevision)revision1;
|
||||
showDiffForDirectory(filePath, left.getHash(), null);
|
||||
}
|
||||
else {
|
||||
GitFileRevision left = (GitFileRevision)revision1;
|
||||
GitFileRevision right = (GitFileRevision)revision2;
|
||||
if (autoSort) {
|
||||
Pair<VcsFileRevision, VcsFileRevision> pair = VcsHistoryUtil.sortRevisions(revision1, revision2);
|
||||
left = (GitFileRevision)pair.first;
|
||||
right = (GitFileRevision)pair.second;
|
||||
}
|
||||
showDiffForDirectory(filePath, left.getHash(), right.getHash());
|
||||
}
|
||||
}
|
||||
|
||||
private void showDiffForMergeCommit(@NotNull final AnActionEvent event, @NotNull final FilePath filePath, @NotNull final GitFileRevision rev,
|
||||
@NotNull final Collection<String> parents) {
|
||||
final AtomicBoolean fileTouched = new AtomicBoolean();
|
||||
new Task.Backgroundable(myProject, "Retrieving revision changes", false) {
|
||||
@Override public void run(@NotNull ProgressIndicator indicator) {
|
||||
private void showDiffForDirectory(@NotNull final FilePath path, @NotNull final String hash1, @Nullable final String hash2) {
|
||||
GitRepository repository = getRepository(path);
|
||||
calculateDiffInBackground(repository, hash1, hash2, new Consumer<List<Change>>() {
|
||||
@Override
|
||||
public void consume(List<Change> changes) {
|
||||
showDirDiffDialog(path, hash1, hash2, changes);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private GitRepository getRepository(@NotNull FilePath path) {
|
||||
VirtualFile file = path.getVirtualFile();
|
||||
LOG.assertTrue(file != null, "VirtualFile can't be null for " + path); // we clicked on a file and asked its history => VF must exist.
|
||||
GitRepository repository = myRepositoryManager.getRepositoryForFile(file);
|
||||
LOG.assertTrue(repository != null, "Repository is null for " + file);
|
||||
return repository;
|
||||
}
|
||||
|
||||
private void calculateDiffInBackground(@NotNull final GitRepository repository, final String hash1, @Nullable final String hash2,
|
||||
final Consumer<List<Change>> successHandler) {
|
||||
new Task.Backgroundable(myProject, "Comparing revisions...") {
|
||||
private List<Change> myChanges;
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
fileTouched.set(wasFileTouched(rev, filePath));
|
||||
myChanges = new ArrayList<Change>(GitChangeUtils.getDiff(repository.getProject(), repository.getRoot(), hash1, hash2));
|
||||
}
|
||||
catch (VcsException e) {
|
||||
LOG.info("Error happened while executing git show " + rev + ":" + filePath, e);
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(GitDiffFromHistoryHandler.this.myProject, e.getMessage(), MessageType.ERROR);
|
||||
showError(e, "Error during requesting diff for directory");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
if (fileTouched.get()) {
|
||||
successHandler.consume(myChanges);
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
|
||||
private void showDirDiffDialog(@NotNull FilePath path, @NotNull String hash1, @Nullable String hash2, @NotNull List<Change> diff) {
|
||||
DialogBuilder dialogBuilder = new DialogBuilder(myProject);
|
||||
String title;
|
||||
if (hash2 != null) {
|
||||
title = String.format("%s diff in %s..%s", path.getName(), GitUtil.getShortHash(hash1), GitUtil.getShortHash(hash2));
|
||||
}
|
||||
else {
|
||||
title = String.format("%s diff from %s", path.getName(), GitUtil.getShortHash(hash1));
|
||||
}
|
||||
dialogBuilder.setTitle(title);
|
||||
dialogBuilder.setActionDescriptors(new DialogBuilder.ActionDescriptor[] { new DialogBuilder.CloseDialogAction()});
|
||||
final ChangesBrowser changesBrowser = new ChangesBrowser(myProject, null, diff, null, false, true,
|
||||
null, ChangesBrowser.MyUseCase.COMMITTED_CHANGES, null);
|
||||
changesBrowser.setChangesToDisplay(diff);
|
||||
dialogBuilder.setCenterPanel(changesBrowser);
|
||||
dialogBuilder.show();
|
||||
}
|
||||
|
||||
private void showDiffForMergeCommit(@NotNull final AnActionEvent event, @NotNull final FilePath filePath,
|
||||
@NotNull final GitFileRevision rev, @NotNull final Collection<String> parents) {
|
||||
|
||||
final Consumer<Boolean> afterTouchCheck = new Consumer<Boolean>() {
|
||||
@Override
|
||||
public void consume(Boolean wasTouched) {
|
||||
if (wasTouched) {
|
||||
String message = filePath.getName() + " did not change in this merge commit";
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(GitDiffFromHistoryHandler.this.myProject, message, MessageType.INFO);
|
||||
}
|
||||
showPopup(event, rev, filePath, parents);
|
||||
}
|
||||
};
|
||||
|
||||
if (filePath.isDirectory()) { // for directories don't check if the file was modified in the merge commit
|
||||
afterTouchCheck.consume(false);
|
||||
}
|
||||
else {
|
||||
checkIfFileWasTouchedInBackground(filePath, rev, afterTouchCheck);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkIfFileWasTouchedInBackground(@NotNull final FilePath filePath, @NotNull final GitFileRevision rev,
|
||||
@NotNull final Consumer<Boolean> afterTouchCheck) {
|
||||
new Task.Backgroundable(myProject, "Loading changes...", false) {
|
||||
private final AtomicBoolean fileTouched = new AtomicBoolean();
|
||||
|
||||
@Override public void run(@NotNull ProgressIndicator indicator) {
|
||||
try {
|
||||
fileTouched.set(wasFileTouched(rev, filePath));
|
||||
}
|
||||
catch (VcsException e) {
|
||||
String logMessage = "Error happened while executing git show " + rev + ":" + filePath;
|
||||
showError(e, logMessage);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
afterTouchCheck.consume(fileTouched.get());
|
||||
}
|
||||
}.queue();
|
||||
}
|
||||
|
||||
private void showError(VcsException e, String logMessage) {
|
||||
LOG.info(logMessage, e);
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(this.myProject, e.getMessage(), MessageType.ERROR);
|
||||
}
|
||||
|
||||
private void showPopup(@NotNull AnActionEvent event, @NotNull GitFileRevision rev, @NotNull FilePath filePath,
|
||||
@NotNull Collection<String> parents) {
|
||||
ActionGroup parentActions = createActionGroup(rev, filePath, parents);
|
||||
@@ -175,10 +281,7 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler {
|
||||
}
|
||||
|
||||
private boolean wasFileTouched(@NotNull GitFileRevision rev, @NotNull FilePath path) throws VcsException {
|
||||
VirtualFile file = path.getVirtualFile();
|
||||
LOG.assertTrue(file != null, "VirtualFile can't be null for " + path); // we clicked on a file and asked its history => VF must exist.
|
||||
GitRepository repository = myRepositoryManager.getRepositoryForFile(file);
|
||||
LOG.assertTrue(repository != null, "Repository is null for " + file);
|
||||
GitRepository repository = getRepository(path);
|
||||
GitCommandResult result = myGit.show(repository, rev + ":" + path);
|
||||
if (result.success()) {
|
||||
return isFilePresentInOutput(repository, path, result.getOutput());
|
||||
@@ -216,9 +319,5 @@ class GitDiffFromHistoryHandler implements DiffFromHistoryHandler {
|
||||
doShowDiff(myFilePath, makeRevisionFromHash(myFilePath, myParentRevision), myRevision, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ import git4idea.branch.GitBranchUtil;
|
||||
import git4idea.history.browser.GitCommit;
|
||||
import git4idea.repo.GitRemote;
|
||||
import git4idea.repo.GitRepository;
|
||||
import git4idea.repo.GitRepositoryManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
@@ -50,6 +50,7 @@ public class GitPushDialog extends DialogWrapper {
|
||||
private static final String DEFAULT_REMOTE = "origin";
|
||||
|
||||
private Project myProject;
|
||||
private final GitRepositoryManager myRepositoryManager;
|
||||
private final GitPusher myPusher;
|
||||
private final GitPushLog myListPanel;
|
||||
private GitCommitsByRepoAndBranch myGitCommitsToPush;
|
||||
@@ -66,8 +67,9 @@ public class GitPushDialog extends DialogWrapper {
|
||||
super(project);
|
||||
myProject = project;
|
||||
myPusher = new GitPusher(myProject, new EmptyProgressIndicator());
|
||||
myRepositoryManager = GitUtil.getRepositoryManager(myProject);
|
||||
|
||||
myRepositories = GitUtil.getRepositoryManager(myProject).getRepositories();
|
||||
myRepositories = getRepositoriesWithRemotes();
|
||||
|
||||
myLoadingPanel = new JBLoadingPanel(new BorderLayout(), this.getDisposable());
|
||||
|
||||
@@ -89,6 +91,17 @@ public class GitPushDialog extends DialogWrapper {
|
||||
setTitle("Git Push");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private List<GitRepository> getRepositoriesWithRemotes() {
|
||||
List<GitRepository> repositories = new ArrayList<GitRepository>();
|
||||
for (GitRepository repository : myRepositoryManager.getRepositories()) {
|
||||
if (!repository.getRemotes().isEmpty()) {
|
||||
repositories.add(repository);
|
||||
}
|
||||
}
|
||||
return repositories;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel optionsPanel = new JPanel(new BorderLayout());
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.tasks.actions.SwitchTaskCombo;
|
||||
import com.intellij.tasks.config.TaskSettings;
|
||||
import com.intellij.testFramework.PlatformTestCase;
|
||||
import com.intellij.testFramework.TestActionEvent;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
|
||||
|
||||
/**
|
||||
@@ -31,10 +30,6 @@ import com.intellij.testFramework.fixtures.CodeInsightFixtureTestCase;
|
||||
*/
|
||||
public class TaskUiTest extends CodeInsightFixtureTestCase {
|
||||
|
||||
public TaskUiTest() {
|
||||
PlatformTestCase.initPlatformPrefix(UsefulTestCase.IDEA_MARKER_CLASS, "PlatformLangXml");
|
||||
}
|
||||
|
||||
public void testTaskComboVisible() throws Exception {
|
||||
|
||||
TaskManager manager = TaskManager.getManager(getProject());
|
||||
@@ -76,4 +71,8 @@ public class TaskUiTest extends CodeInsightFixtureTestCase {
|
||||
return event.getPresentation();
|
||||
}
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public TaskUiTest() {
|
||||
PlatformTestCase.initPlatformLangPrefix();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user