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
67f11192
Commit
67f11192
authored
7 years ago
by
Vassiliy.Kudryashov
Browse files
Options
Download
Email Patches
Plain Diff
GDPR support: improvements in Consents-related UX
parent
1241ebe3
Branches unavailable
Tags unavailable
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
platform/platform-impl/src/com/intellij/ui/AppUIUtil.java
+42
-30
platform/platform-impl/src/com/intellij/ui/AppUIUtil.java
with
42 additions
and
30 deletions
+42
-30
platform/platform-impl/src/com/intellij/ui/AppUIUtil.java
+
42
-
30
View file @
67f11192
...
...
@@ -371,11 +371,22 @@ public class AppUIUtil {
public
static
Collection
<
Consent
>
confirmConsentOptions
(
@NotNull
Collection
<
Consent
>
consents
)
{
final
Collection
<
Pair
<
JCheckBox
,
Consent
>>
consentMapping
=
new
ArrayList
<>();
final
DialogWrapper
dialog
=
new
DialogWrapper
(
true
)
{
@Nullable
@Override
protected
Border
createContentPaneBorder
()
{
return
null
;
}
@Override
protected
JComponent
createCenterPanel
()
{
final
JPanel
mainPanel
=
new
JPanel
(
new
BorderLayout
(
JBUI
.
scale
(
5
),
JBUI
.
scale
(
5
)));
final
JPanel
body
=
new
JPanel
(
new
GridBagLayout
());
//noinspection UseDPIAwareInsets
body
.
add
(
new
JLabel
(
"Please review your options regarding the sharing your data with JetBrains:"
),
new
GridBagConstraints
(
0
,
GridBagConstraints
.
RELATIVE
,
1
,
1
,
1.0
,
0.0
,
GridBagConstraints
.
NORTH
,
GridBagConstraints
.
BOTH
,
new
Insets
(
JBUI
.
scale
(
10
),
getLeftTextMargin
(
new
JCheckBox
()),
JBUI
.
scale
(
10
),
0
),
0
,
0
));
for
(
Iterator
<
Consent
>
it
=
consents
.
iterator
();
it
.
hasNext
();
)
{
final
Consent
consent
=
it
.
next
();
final
JComponent
comp
=
createConsentElement
(
consent
);
...
...
@@ -387,10 +398,8 @@ public class AppUIUtil {
0
,
GridBagConstraints
.
RELATIVE
,
1
,
1
,
1.0
,
lastConsent
?
1.0
:
0.0
,
GridBagConstraints
.
NORTHWEST
,
GridBagConstraints
.
BOTH
,
JBUI
.
insets
(
10
,
0
,
0
,
0
),
0
,
0
)
);
}
mainPanel
.
add
(
new
JLabel
(
"Please review your options regarding the sharing your data with JetBrains"
),
BorderLayout
.
NORTH
);
mainPanel
.
add
(
new
JBScrollPane
(
body
,
VERTICAL_SCROLLBAR_AS_NEEDED
,
HORIZONTAL_SCROLLBAR_NEVER
),
BorderLayout
.
CENTER
);
return
mainPanel
;
body
.
setBorder
(
JBUI
.
Borders
.
empty
(
10
));
return
new
JBScrollPane
(
body
,
VERTICAL_SCROLLBAR_AS_NEEDED
,
HORIZONTAL_SCROLLBAR_NEVER
);
}
@NotNull
...
...
@@ -419,30 +428,13 @@ public class AppUIUtil {
styleSheet
.
addRule
(
"li {margin-bottom:"
+
JBUI
.
scaleFontSize
(
6
)
+
"pt;}"
);
styleSheet
.
addRule
(
"h2 {margin-top:0;padding-top:"
+
JBUI
.
scaleFontSize
(
13
)+
"pt;}"
);
viewer
.
setCaretPosition
(
0
);
viewer
.
setBorder
(
JBUI
.
Borders
.
empty
(
0
,
5
,
5
,
5
));
final
JCheckBox
cb
=
new
JBCheckBox
(
consent
.
getName
(),
consent
.
isAccepted
());
cb
.
setBackground
(
viewer
.
getBackground
());
cb
.
setFont
(
cb
.
getFont
().
deriveFont
(
Font
.
BOLD
));
int
leftInset
=
0
;
Insets
margin
=
cb
.
getMargin
();
if
(
margin
!=
null
)
leftInset
+=
margin
.
left
;
Border
border
=
cb
.
getBorder
();
if
(
border
!=
null
)
leftInset
+=
border
.
getBorderInsets
(
cb
).
left
;
ButtonUI
ui
=
cb
.
getUI
();
Icon
icon
=
null
;
if
(
ui
instanceof
BasicRadioButtonUI
)
{
icon
=
((
BasicRadioButtonUI
)
ui
).
getDefaultIcon
();
}
else
if
(
ui
instanceof
SynthCheckBoxUI
){
SynthCheckBoxUI
sui
=
(
SynthCheckBoxUI
)
ui
;
SynthContext
context
=
sui
.
getContext
(
cb
);
icon
=
context
.
getStyle
().
getIcon
(
context
,
"CheckBox.icon"
);
}
if
(
icon
!=
null
)
{
leftInset
+=
icon
.
getIconWidth
()
+
cb
.
getIconTextGap
();
//noinspection UseDPIAwareBorders
}
viewer
.
setBorder
(
new
EmptyBorder
(
JBUI
.
scale
(
5
),
leftInset
,
JBUI
.
scale
(
15
),
JBUI
.
scale
(
5
)));
int
leftInset
=
getLeftTextMargin
(
cb
);
//noinspection UseDPIAwareBorders
viewer
.
setBorder
(
new
EmptyBorder
(
JBUI
.
scale
(
5
),
leftInset
,
JBUI
.
scale
(
15
),
0
));
final
JPanel
pane
=
new
JPanel
(
new
BorderLayout
());
pane
.
setBackground
(
viewer
.
getBackground
());
...
...
@@ -452,11 +444,6 @@ public class AppUIUtil {
return
pane
;
}
@NotNull
protected
Action
[]
createActions
()
{
return
new
Action
[]
{
getOKAction
()};
}
@Override
protected
void
createDefaultActions
()
{
super
.
createDefaultActions
();
...
...
@@ -506,4 +493,29 @@ public class AppUIUtil {
GraphicsConfiguration
gc
=
target
!=
null
?
target
.
getGraphicsConfiguration
()
:
null
;
AWTAccessor
.
getComponentAccessor
().
setGraphicsConfiguration
(
comp
,
gc
);
}
/**
* Returns distance (px) from the left edge to actual text position for specified checkbox.
* It may be used as left margin when you need to align text in a label located above or below the checkbox
*/
public
static
int
getLeftTextMargin
(
@NotNull
JCheckBox
checkBox
)
{
int
leftMargin
=
0
;
Insets
margin
=
checkBox
.
getMargin
();
if
(
margin
!=
null
)
leftMargin
+=
margin
.
left
;
Border
border
=
checkBox
.
getBorder
();
if
(
border
!=
null
)
leftMargin
+=
border
.
getBorderInsets
(
checkBox
).
left
;
ButtonUI
ui
=
checkBox
.
getUI
();
Icon
icon
=
null
;
if
(
ui
instanceof
BasicRadioButtonUI
)
{
icon
=
((
BasicRadioButtonUI
)
ui
).
getDefaultIcon
();
}
else
if
(
ui
instanceof
SynthCheckBoxUI
){
SynthCheckBoxUI
sui
=
(
SynthCheckBoxUI
)
ui
;
SynthContext
context
=
sui
.
getContext
(
checkBox
);
icon
=
context
.
getStyle
().
getIcon
(
context
,
"CheckBox.icon"
);
}
if
(
icon
!=
null
)
{
leftMargin
+=
icon
.
getIconWidth
()
+
checkBox
.
getIconTextGap
();
}
return
leftMargin
;
}
}
\ No newline at end of file
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