Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
890a6097
Commit
890a6097
authored
6 years ago
by
Julia Beliaeva
Browse files
Options
Download
Email Patches
Plain Diff
[file-history] move diff preview to FileHistoryPanel from FileHistoryUi
parent
cc05e9e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryPanel.java
+45
-2
...pl/src/com/intellij/vcs/log/history/FileHistoryPanel.java
platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryUi.java
+3
-42
.../impl/src/com/intellij/vcs/log/history/FileHistoryUi.java
with
48 additions
and
44 deletions
+48
-44
platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryPanel.java
+
45
-
2
View file @
890a6097
...
...
@@ -17,6 +17,7 @@ package com.intellij.vcs.log.history;
import
com.intellij.openapi.Disposable
;
import
com.intellij.openapi.actionSystem.*
;
import
com.intellij.openapi.application.ApplicationManager
;
import
com.intellij.openapi.util.Disposer
;
import
com.intellij.openapi.vcs.FilePath
;
import
com.intellij.openapi.vcs.VcsDataKeys
;
...
...
@@ -24,6 +25,7 @@ import com.intellij.openapi.vcs.changes.Change;
import
com.intellij.openapi.vcs.history.VcsFileRevision
;
import
com.intellij.openapi.vfs.VirtualFile
;
import
com.intellij.ui.*
;
import
com.intellij.ui.components.JBPanel
;
import
com.intellij.util.containers.ContainerUtil
;
import
com.intellij.vcs.log.CommitId
;
import
com.intellij.vcs.log.VcsCommitMetadata
;
...
...
@@ -44,8 +46,10 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.annotations.Nullable
;
import
javax.swing.*
;
import
javax.swing.event.ListSelectionListener
;
import
java.awt.*
;
import
java.awt.event.MouseEvent
;
import
java.util.Arrays
;
import
java.util.List
;
import
static
com
.
intellij
.
util
.
ObjectUtils
.
notNull
;
...
...
@@ -55,6 +59,9 @@ public class FileHistoryPanel extends JPanel implements DataProvider, Disposable
@NotNull
private
final
VcsLogGraphTable
myGraphTable
;
@NotNull
private
final
DetailsPanel
myDetailsPanel
;
@NotNull
private
final
JBSplitter
myDetailsSplitter
;
@Nullable
private
final
FileHistoryDiffPreview
myDiffPreview
;
@NotNull
private
final
OnePixelSplitter
myDiffPreviewSplitter
;
@NotNull
private
final
FilePath
myFilePath
;
@NotNull
private
final
FileHistoryUi
myUi
;
@NotNull
private
final
VirtualFile
myRoot
;
...
...
@@ -101,9 +108,31 @@ public class FileHistoryPanel extends JPanel implements DataProvider, Disposable
myDetailsPanel
.
installCommitSelectionListener
(
myGraphTable
);
VcsLogUiUtil
.
installDetailsListeners
(
myGraphTable
,
myDetailsPanel
,
logData
,
this
);
JBPanel
tablePanel
=
new
JBPanel
(
new
BorderLayout
());
tablePanel
.
add
(
myDetailsSplitter
,
BorderLayout
.
CENTER
);
tablePanel
.
add
(
createActionsToolbar
(),
BorderLayout
.
WEST
);
if
(!
myFilePath
.
isDirectory
())
{
myDiffPreview
=
new
FileHistoryDiffPreview
(
myUi
.
getLogData
().
getProject
(),
()
->
myUi
.
getSelectedChange
(),
this
);
ListSelectionListener
selectionListener
=
e
->
{
int
[]
selection
=
myGraphTable
.
getSelectedRows
();
ApplicationManager
.
getApplication
()
.
invokeLater
(()
->
myDiffPreview
.
updatePreview
(
myUi
.
getProperties
().
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
)),
o
->
!
Arrays
.
equals
(
selection
,
myGraphTable
.
getSelectedRows
()));
};
myGraphTable
.
getSelectionModel
().
addListSelectionListener
(
selectionListener
);
}
else
{
myDiffPreview
=
null
;
}
myDiffPreviewSplitter
=
new
OnePixelSplitter
(
false
,
"vcs.history.diff.splitter.proportion"
,
0.7f
);
myDiffPreviewSplitter
.
setHonorComponentsMinimumSize
(
false
);
myDiffPreviewSplitter
.
setFirstComponent
(
tablePanel
);
ApplicationManager
.
getApplication
().
invokeLater
(()
->
showDiffPreview
(
myUi
.
getProperties
().
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
)));
setLayout
(
new
BorderLayout
());
add
(
myDetailsSplitter
,
BorderLayout
.
CENTER
);
add
(
createActionsToolbar
(),
BorderLayout
.
WEST
);
add
(
myDiffPreviewSplitter
,
BorderLayout
.
CENTER
);
PopupHandler
.
installPopupHandler
(
myGraphTable
,
VcsLogActionPlaces
.
HISTORY_POPUP_ACTION_GROUP
,
VcsLogActionPlaces
.
VCS_HISTORY_PLACE
);
invokeOnDoubleClick
(
ActionManager
.
getInstance
().
getAction
(
VcsLogActionPlaces
.
VCS_LOG_SHOW_DIFF_ACTION
),
tableWithProgress
);
...
...
@@ -142,12 +171,26 @@ public class FileHistoryPanel extends JPanel implements DataProvider, Disposable
public
void
updateDataPack
(
@NotNull
VisiblePack
visiblePack
,
boolean
permanentGraphChanged
)
{
myGraphTable
.
updateDataPack
(
visiblePack
,
permanentGraphChanged
);
if
(
myDiffPreview
!=
null
)
{
myDiffPreview
.
updatePreview
(
myUi
.
getProperties
().
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
));
}
}
public
void
showDetails
(
boolean
show
)
{
myDetailsSplitter
.
setSecondComponent
(
show
?
myDetailsPanel
:
null
);
}
public
boolean
hasDiffPreview
()
{
return
myDiffPreview
!=
null
;
}
void
showDiffPreview
(
boolean
state
)
{
if
(
myDiffPreview
!=
null
)
{
myDiffPreview
.
updatePreview
(
state
);
myDiffPreviewSplitter
.
setSecondComponent
(
state
?
myDiffPreview
.
getComponent
()
:
null
);
}
}
@Nullable
@Override
public
Object
getData
(
@NotNull
String
dataId
)
{
...
...
This diff is collapsed.
Click to expand it.
platform/vcs-log/impl/src/com/intellij/vcs/log/history/FileHistoryUi.java
+
3
-
42
View file @
890a6097
...
...
@@ -2,7 +2,6 @@
package
com.intellij.vcs.log.history
;
import
com.google.common.util.concurrent.SettableFuture
;
import
com.intellij.openapi.application.ApplicationManager
;
import
com.intellij.openapi.util.Condition
;
import
com.intellij.openapi.util.Conditions
;
import
com.intellij.openapi.vcs.FilePath
;
...
...
@@ -10,7 +9,6 @@ import com.intellij.openapi.vcs.changes.Change;
import
com.intellij.openapi.vcs.history.VcsFileRevision
;
import
com.intellij.openapi.vfs.VirtualFile
;
import
com.intellij.ui.JBColor
;
import
com.intellij.ui.OnePixelSplitter
;
import
com.intellij.ui.navigation.History
;
import
com.intellij.util.PairFunction
;
import
com.intellij.util.containers.ContainerUtil
;
...
...
@@ -37,8 +35,6 @@ import com.intellij.vcs.log.visible.VisiblePackRefresher;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.Nullable
;
import
javax.swing.*
;
import
javax.swing.event.ListSelectionListener
;
import
java.awt.*
;
import
java.util.List
;
import
java.util.*
;
...
...
@@ -56,9 +52,6 @@ public class FileHistoryUi extends AbstractVcsLogUi {
@NotNull
private
final
FileHistoryUiProperties
myUiProperties
;
@NotNull
private
final
FileHistoryFilterUi
myFilterUi
;
@NotNull
private
final
FileHistoryPanel
myFileHistoryPanel
;
@Nullable
private
final
FileHistoryDiffPreview
myDiffPreview
;
@Nullable
private
final
OnePixelSplitter
myDiffPreviewSplitter
;
@NotNull
private
final
JComponent
myMainComponent
;
@NotNull
private
final
Set
<
String
>
myHighlighterIds
;
@NotNull
private
final
MyPropertiesChangeListener
myPropertiesChangeListener
;
@NotNull
private
final
History
myHistory
;
...
...
@@ -82,28 +75,6 @@ public class FileHistoryUi extends AbstractVcsLogUi {
myFilterUi
=
new
FileHistoryFilterUi
(
path
,
revision
,
root
,
uiProperties
);
myFileHistoryPanel
=
new
FileHistoryPanel
(
this
,
logData
,
myVisiblePack
,
path
);
if
(!
myPath
.
isDirectory
())
{
myDiffPreview
=
new
FileHistoryDiffPreview
(
myProject
,
()
->
getSelectedChange
(),
this
);
ListSelectionListener
selectionListener
=
e
->
{
int
[]
selection
=
getTable
().
getSelectedRows
();
ApplicationManager
.
getApplication
()
.
invokeLater
(()
->
myDiffPreview
.
updatePreview
(
myUiProperties
.
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
)),
o
->
!
Arrays
.
equals
(
selection
,
getTable
().
getSelectedRows
()));
};
getTable
().
getSelectionModel
().
addListSelectionListener
(
selectionListener
);
myDiffPreviewSplitter
=
new
OnePixelSplitter
(
false
,
"vcs.history.diff.splitter.proportion"
,
0.7f
);
myDiffPreviewSplitter
.
setHonorComponentsMinimumSize
(
false
);
myDiffPreviewSplitter
.
setFirstComponent
(
myFileHistoryPanel
);
showDiffPreview
(
myUiProperties
.
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
));
myMainComponent
=
myDiffPreviewSplitter
;
}
else
{
myDiffPreview
=
null
;
myDiffPreviewSplitter
=
null
;
myMainComponent
=
myFileHistoryPanel
;
}
myHighlighterIds
=
myRevision
==
null
?
ContainerUtil
.
newHashSet
(
MyCommitsHighlighter
.
Factory
.
ID
,
CurrentBranchHighlighter
.
Factory
.
ID
)
...
...
@@ -128,7 +99,7 @@ public class FileHistoryUi extends AbstractVcsLogUi {
}
public
boolean
hasDiffPreview
()
{
return
myDiffPreview
!=
null
;
return
my
FileHistoryPanel
.
has
DiffPreview
()
;
}
@Nullable
...
...
@@ -220,13 +191,6 @@ public class FileHistoryUi extends AbstractVcsLogUi {
return
myPath
.
equals
(
targetPath
)
&&
Objects
.
equals
(
myRevision
,
targetRevision
);
}
private
void
showDiffPreview
(
boolean
state
)
{
if
(
myDiffPreview
!=
null
)
{
myDiffPreview
.
updatePreview
(
state
);
myDiffPreviewSplitter
.
setSecondComponent
(
state
?
myDiffPreview
.
getComponent
()
:
null
);
}
}
@NotNull
@Override
public
VcsLogFilterUi
getFilterUi
()
{
...
...
@@ -241,9 +205,6 @@ public class FileHistoryUi extends AbstractVcsLogUi {
@Override
protected
void
onVisiblePackUpdated
(
boolean
permGraphChanged
)
{
myFileHistoryPanel
.
updateDataPack
(
myVisiblePack
,
permGraphChanged
);
if
(
myDiffPreview
!=
null
)
{
myDiffPreview
.
updatePreview
(
myUiProperties
.
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
));
}
}
@NotNull
...
...
@@ -255,7 +216,7 @@ public class FileHistoryUi extends AbstractVcsLogUi {
@NotNull
@Override
public
Component
getMainComponent
()
{
return
my
MainComponent
;
return
my
FileHistoryPanel
;
}
@Nullable
...
...
@@ -302,7 +263,7 @@ public class FileHistoryUi extends AbstractVcsLogUi {
getTable
().
forceReLayout
(((
CommonUiProperties
.
TableColumnProperty
)
property
).
getColumn
());
}
else
if
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
.
equals
(
property
))
{
showDiffPreview
(
myUiProperties
.
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
));
myFileHistoryPanel
.
showDiffPreview
(
myUiProperties
.
get
(
CommonUiProperties
.
SHOW_DIFF_PREVIEW
));
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment