Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
5d838b89
Commit
5d838b89
authored
6 years ago
by
Aleksey Pivovarov
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-203490 vcs: allow to copy revision info from Local History
parent
b928968c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
platform/lvcs-impl/src/com/intellij/history/integration/ui/views/RevisionsList.java
+56
-2
.../intellij/history/integration/ui/views/RevisionsList.java
with
56 additions
and
2 deletions
+56
-2
platform/lvcs-impl/src/com/intellij/history/integration/ui/views/RevisionsList.java
+
56
-
2
View file @
5d838b89
...
@@ -6,6 +6,11 @@ import com.intellij.history.core.revisions.Revision;
...
@@ -6,6 +6,11 @@ import com.intellij.history.core.revisions.Revision;
import
com.intellij.history.integration.LocalHistoryBundle
;
import
com.intellij.history.integration.LocalHistoryBundle
;
import
com.intellij.history.integration.ui.models.HistoryDialogModel
;
import
com.intellij.history.integration.ui.models.HistoryDialogModel
;
import
com.intellij.history.integration.ui.models.RevisionItem
;
import
com.intellij.history.integration.ui.models.RevisionItem
;
import
com.intellij.ide.CopyProvider
;
import
com.intellij.ide.DataManager
;
import
com.intellij.openapi.actionSystem.DataContext
;
import
com.intellij.openapi.actionSystem.PlatformDataKeys
;
import
com.intellij.openapi.ide.CopyPasteManager
;
import
com.intellij.openapi.util.Pair
;
import
com.intellij.openapi.util.Pair
;
import
com.intellij.openapi.util.text.StringUtil
;
import
com.intellij.openapi.util.text.StringUtil
;
import
com.intellij.openapi.vcs.VcsBundle
;
import
com.intellij.openapi.vcs.VcsBundle
;
...
@@ -18,10 +23,12 @@ import com.intellij.ui.table.JBTable;
...
@@ -18,10 +23,12 @@ import com.intellij.ui.table.JBTable;
import
com.intellij.util.text.DateFormatUtil
;
import
com.intellij.util.text.DateFormatUtil
;
import
com.intellij.util.ui.AbstractLayoutManager
;
import
com.intellij.util.ui.AbstractLayoutManager
;
import
com.intellij.util.ui.JBInsets
;
import
com.intellij.util.ui.JBInsets
;
import
com.intellij.util.ui.TextTransferable
;
import
com.intellij.util.ui.UIUtil
;
import
com.intellij.util.ui.UIUtil
;
import
com.intellij.util.ui.accessibility.AccessibleContextUtil
;
import
com.intellij.util.ui.accessibility.AccessibleContextUtil
;
import
gnu.trove.THashMap
;
import
gnu.trove.THashMap
;
import
gnu.trove.THashSet
;
import
gnu.trove.THashSet
;
import
org.jetbrains.annotations.NotNull
;
import
javax.accessibility.AccessibleContext
;
import
javax.accessibility.AccessibleContext
;
import
javax.accessibility.AccessibleRole
;
import
javax.accessibility.AccessibleRole
;
...
@@ -32,6 +39,7 @@ import javax.swing.event.ListSelectionListener;
...
@@ -32,6 +39,7 @@ import javax.swing.event.ListSelectionListener;
import
javax.swing.table.AbstractTableModel
;
import
javax.swing.table.AbstractTableModel
;
import
javax.swing.table.DefaultTableCellRenderer
;
import
javax.swing.table.DefaultTableCellRenderer
;
import
javax.swing.table.TableCellRenderer
;
import
javax.swing.table.TableCellRenderer
;
import
javax.swing.table.TableModel
;
import
java.awt.*
;
import
java.awt.*
;
import
java.util.List
;
import
java.util.List
;
import
java.util.*
;
import
java.util.*
;
...
@@ -56,6 +64,14 @@ public class RevisionsList {
...
@@ -56,6 +64,14 @@ public class RevisionsList {
table
.
getEmptyText
().
setText
(
VcsBundle
.
message
(
"history.empty"
));
table
.
getEmptyText
().
setText
(
VcsBundle
.
message
(
"history.empty"
));
addSelectionListener
(
l
);
addSelectionListener
(
l
);
CopyProvider
copyProvider
=
new
MyCellRenderer
.
MyCopyProvider
(
table
);
DataManager
.
registerDataProvider
(
table
,
dataId
->
{
if
(
PlatformDataKeys
.
COPY_PROVIDER
.
is
(
dataId
))
{
return
copyProvider
;
}
return
null
;
});
}
}
public
JComponent
getComponent
()
{
public
JComponent
getComponent
()
{
...
@@ -335,11 +351,11 @@ public class RevisionsList {
...
@@ -335,11 +351,11 @@ public class RevisionsList {
return
myWrapperPanel
;
return
myWrapperPanel
;
}
}
private
String
ensureString
(
String
s
)
{
private
static
String
ensureString
(
String
s
)
{
return
StringUtil
.
isEmpty
(
s
)
?
" "
:
s
;
return
StringUtil
.
isEmpty
(
s
)
?
" "
:
s
;
}
}
private
LabelsAndColor
getLabelsAndColor
(
RevisionItem
item
)
{
private
static
LabelsAndColor
getLabelsAndColor
(
RevisionItem
item
)
{
Revision
r
=
item
.
revision
;
Revision
r
=
item
.
revision
;
final
Pair
<
List
<
String
>,
Integer
>
affected
=
r
.
getAffectedFileNames
();
final
Pair
<
List
<
String
>,
Integer
>
affected
=
r
.
getAffectedFileNames
();
...
@@ -459,5 +475,43 @@ public class RevisionsList {
...
@@ -459,5 +475,43 @@ public class RevisionsList {
g2d
.
dispose
();
g2d
.
dispose
();
}
}
}
}
private
static
class
MyCopyProvider
implements
CopyProvider
{
@NotNull
private
final
JBTable
myTable
;
private
MyCopyProvider
(
@NotNull
JBTable
table
)
{
myTable
=
table
;
}
@Override
public
void
performCopy
(
@NotNull
DataContext
dataContext
)
{
TableModel
model
=
myTable
.
getModel
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
int
row
:
myTable
.
getSelectedRows
())
{
RevisionItem
r
=
(
RevisionItem
)
model
.
getValueAt
(
row
,
0
);
LabelsAndColor
labelsAndColor
=
getLabelsAndColor
(
r
);
String
time
=
DateFormatUtil
.
formatDateTime
(
r
.
revision
.
getTimestamp
());
String
title
=
labelsAndColor
.
title
;
String
filesCount
=
labelsAndColor
.
filesCount
;
if
(
sb
.
length
()
!=
0
)
sb
.
append
(
"\n"
);
sb
.
append
(
time
).
append
(
", "
)
.
append
(
filesCount
).
append
(
": "
)
.
append
(
title
);
}
CopyPasteManager
.
getInstance
().
setContents
(
new
TextTransferable
(
sb
.
toString
()));
}
@Override
public
boolean
isCopyEnabled
(
@NotNull
DataContext
dataContext
)
{
return
myTable
.
getSelectedRowCount
()
>
0
;
}
@Override
public
boolean
isCopyVisible
(
@NotNull
DataContext
dataContext
)
{
return
true
;
}
}
}
}
}
}
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
Menu
Projects
Groups
Snippets
Help