From be23bf0caa3014bc35e5e51b914318c1c13562a0 Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 20 Dec 2011 17:07:23 +0400 Subject: [PATCH 1/2] file history: "Show Details" action --- .../openapi/vcs/VcsConfiguration.java | 1 + .../vcs/history/FileHistoryPanelImpl.java | 35 +++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java index 0030810d4fb5..9cdb8544f8c5 100644 --- a/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java +++ b/platform/vcs-api/src/com/intellij/openapi/vcs/VcsConfiguration.java @@ -89,6 +89,7 @@ public final class VcsConfiguration implements PersistentStateComponent public boolean INCLUDE_TEXT_INTO_SHELF = false; public boolean CREATE_PATCH_EXPAND_DETAILS_DEFAULT = true; public Boolean SHOW_PATCH_IN_EXPLORER = null; + public boolean SHOW_FILE_HISTORY_DETAILS = true; public enum StandardOption { ADD(VcsBundle.message("vcs.command.name.add")), diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 0cfcf6df3b90..3dd441f58509 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -169,6 +169,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { return DateFormatUtil.formatPrettyDateTime(Clock.getTime()); } }; + private final Splitter myDetailsSplitter = new Splitter(false, 0.5f); public void scheduleRefresh() { ApplicationManager.getApplication().invokeLater(new Runnable() { @@ -671,8 +672,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { } }); - final Splitter detailsSplitter = new Splitter(false, 0.5f); - JPanel commentGroup = new JPanel(new BorderLayout(4, 4)); + JPanel commentGroup = new JPanel(new BorderLayout()); final JLabel commentLabel = new JLabel(COMMIT_MESSAGE_TITLE + ":") { @Override public Dimension getPreferredSize() { @@ -684,16 +684,27 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { pane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.LEFT | (myAdditionalDetails == null ? 0 : SideBorder.BOTTOM))); commentGroup.add(pane, BorderLayout.CENTER); - detailsSplitter.setFirstComponent(commentGroup); - detailsSplitter.setSecondComponent(myAdditionalDetails); + myDetailsSplitter.setFirstComponent(commentGroup); + myDetailsSplitter.setSecondComponent(myAdditionalDetails); - myDualView.setViewBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.BOTTOM)); mySplitter.setFirstComponent(myDualView); - mySplitter.setSecondComponent(detailsSplitter); + setupDetails(); return mySplitter; } + private void setupDetails() { + boolean showDetails = getConfiguration().SHOW_FILE_HISTORY_DETAILS; + if (showDetails) { + myDualView.setViewBorder(IdeBorderFactory.createBorder(SideBorder.LEFT | SideBorder.BOTTOM)); + } + else { + myDualView.setViewBorder(IdeBorderFactory.createBorder(SideBorder.LEFT)); + } + + mySplitter.setSecondComponent(showDetails ? myDetailsSplitter : null); + } + private void chooseView() { if (showTree()) { myDualView.switchToTheTreeMode(); @@ -773,6 +784,18 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { } } result.add(new RefreshFileHistoryAction()); + result.add(new ToggleAction("Show Details", "Display details panel", IconLoader.getIcon("/actions/showSource.png")) { + @Override + public boolean isSelected(AnActionEvent e) { + return getConfiguration().SHOW_FILE_HISTORY_DETAILS; + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + getConfiguration().SHOW_FILE_HISTORY_DETAILS = state; + setupDetails(); + } + }); if (!popup && supportsTree()) { result.add(new MyShowAsTreeAction()); From 99da5f4a68f587d12749be1342f0bfc58fbaf36d Mon Sep 17 00:00:00 2001 From: Dmitry Avdeev Date: Tue, 20 Dec 2011 17:08:58 +0400 Subject: [PATCH 2/2] cleanup --- .../vcs/history/FileHistoryPanelImpl.java | 1 - .../git4idea/history/wholeTree/GitLogUI.java | 26 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 3dd441f58509..067e69136f59 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -687,7 +687,6 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton { myDetailsSplitter.setFirstComponent(commentGroup); myDetailsSplitter.setSecondComponent(myAdditionalDetails); - mySplitter.setFirstComponent(myDualView); setupDetails(); return mySplitter; diff --git a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java index b11ca9700bc9..ece7fc0e9bab 100644 --- a/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java +++ b/plugins/git4idea/src/git4idea/history/wholeTree/GitLogUI.java @@ -129,7 +129,6 @@ public class GitLogUI implements Disposable { private MyRefreshAction myRefreshAction; private MyStructureFilter myStructureFilter; private StructureFilterAction myStructureFilterAction; - private ToggleAction myShowDetailsAction; private AnAction myCopyHashAction; // todo group somewhere?? private Consumer myDetailsLoaderImpl; @@ -865,19 +864,20 @@ public class GitLogUI implements Disposable { myRootsAction = new MyRootsAction(rootsGetter, myJBTable); group.add(myRootsAction); group.add(myMyShowTreeAction); - myShowDetailsAction = new ToggleAction("Show Details", "Display details panel", IconLoader.getIcon("/actions/showSource.png")) { - @Override - public boolean isSelected(AnActionEvent e) { - return GitLogSettings.getInstance(myProject).isShowDetails(); - } - @Override - public void setSelected(AnActionEvent e, boolean state) { - setupDetailsSplitter(state); - GitLogSettings.getInstance(myProject).setShowDetails(state); - } - }; - group.add(myShowDetailsAction); + group.add(new ToggleAction("Show Details", "Display details panel", IconLoader.getIcon("/actions/showSource.png")) { + @Override + public boolean isSelected(AnActionEvent e) { + return GitLogSettings.getInstance(myProject).isShowDetails(); + } + + @Override + public void setSelected(AnActionEvent e, boolean state) { + setupDetailsSplitter(state); + GitLogSettings.getInstance(myProject).setShowDetails(state); + } + }); + myMyGotoCommitAction = new MyGotoCommitAction(); group.add(myMyGotoCommitAction); group.add(myRefreshAction);