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
0f8a72ec
Commit
0f8a72ec
authored
6 years ago
by
Kirill Kirichenko
Browse files
Options
Download
Email Patches
Plain Diff
IDEA-190436 Enable scrolltab support. Initial branch commit.
parent
4bce734c
Branches unavailable
Tags unavailable
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
platform/platform-api/src/com/intellij/ui/components/JBTabbedPane.java
+2
-1
...form-api/src/com/intellij/ui/components/JBTabbedPane.java
platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaTabbedPaneUI.java
+111
-0
...m/intellij/ide/ui/laf/darcula/ui/DarculaTabbedPaneUI.java
platform/platform-impl/src/com/intellij/internal/ui/ComponentPanelTestAction.java
+1
-1
...rc/com/intellij/internal/ui/ComponentPanelTestAction.java
with
114 additions
and
2 deletions
+114
-2
platform/platform-api/src/com/intellij/ui/components/JBTabbedPane.java
+
2
-
1
View file @
0f8a72ec
...
...
@@ -19,6 +19,7 @@ import com.intellij.openapi.util.SystemInfo;
import
com.intellij.ui.JBColor
;
import
com.intellij.ui.ScreenUtil
;
import
com.intellij.util.ui.JBSwingUtilities
;
import
com.intellij.util.ui.JBUI
;
import
com.intellij.util.ui.UIUtil
;
import
org.intellij.lang.annotations.JdkConstants
;
import
org.jetbrains.annotations.NonNls
;
...
...
@@ -65,7 +66,7 @@ public class JBTabbedPane extends JTabbedPane implements HierarchyListener {
//set custom label for correct work spotlighting in settings
JLabel
label
=
new
JLabel
(
title
);
label
.
setIcon
(
icon
);
label
.
setBorder
(
new
EmptyBorder
(
1
,
1
,
1
,
1
));
label
.
setBorder
(
JBUI
.
Borders
.
empty
(
1
));
setTabComponentAt
(
index
,
label
);
updateSelectedTabForeground
();
label
.
putClientProperty
(
LABEL_FROM_TABBED_PANE
,
Boolean
.
TRUE
);
...
...
This diff is collapsed.
Click to expand it.
platform/platform-impl/src/com/intellij/ide/ui/laf/darcula/ui/DarculaTabbedPaneUI.java
+
111
-
0
View file @
0f8a72ec
...
...
@@ -22,7 +22,10 @@ import com.intellij.util.ui.JBValue;
import
sun.swing.SwingUtilities2
;
import
javax.swing.*
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
import
javax.swing.plaf.ComponentUI
;
import
javax.swing.plaf.UIResource
;
import
javax.swing.plaf.basic.BasicTabbedPaneUI
;
import
javax.swing.text.View
;
import
java.awt.*
;
...
...
@@ -30,6 +33,7 @@ import java.awt.event.*;
import
java.beans.PropertyChangeListener
;
import
static
com
.
intellij
.
util
.
ui
.
JBUI
.
CurrentTheme
.
Focus
.
TabbedPane
.*;
import
static
javax
.
swing
.
JViewport
.
SIMPLE_SCROLL_MODE
;
/**
* @author Konstantin Bulenkov
...
...
@@ -257,4 +261,111 @@ public class DarculaTabbedPaneUI extends BasicTabbedPaneUI {
@Override
protected
void
paintContentBorderBottomEdge
(
Graphics
g
,
int
tabPlacement
,
int
selectedIndex
,
int
x
,
int
y
,
int
w
,
int
h
)
{}
/***********************************************************************************************************************
* Scrollable tab pane layout
*/
private
ScrollableTabSupport
tabScroller
;
//@Override
//protected LayoutManager createLayoutManager() {
// return (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) ?
// new TabbedPaneScrollLayout() :
// new TabbedPaneLayout();
//}
private
boolean
scrollableTabLayoutEnabled
()
{
return
(
tabPane
.
getLayout
()
instanceof
TabbedPaneScrollLayout
);
}
@Override
protected
void
installComponents
()
{
if
(
scrollableTabLayoutEnabled
())
{
if
(
tabScroller
==
null
)
{
tabScroller
=
new
ScrollableTabSupport
();
tabPane
.
add
(
tabScroller
.
viewport
);
}
}
else
{
super
.
installComponents
();
}
}
@Override
protected
void
uninstallComponents
()
{
if
(
scrollableTabLayoutEnabled
())
{
tabPane
.
remove
(
tabScroller
.
viewport
);
}
else
{
super
.
uninstallComponents
();
}
}
private
class
TabbedPaneScrollLayout
extends
TabbedPaneLayout
{
@Override
protected
int
preferredTabAreaHeight
(
int
tabPlacement
,
int
width
)
{
return
calculateMaxTabHeight
(
tabPlacement
);
}
@Override
protected
int
preferredTabAreaWidth
(
int
tabPlacement
,
int
height
)
{
return
calculateMaxTabWidth
(
tabPlacement
);
}
}
private
class
ScrollableTabSupport
implements
ActionListener
,
ChangeListener
{
private
final
JViewport
viewport
;
private
final
JPanel
tabPanel
;
private
JButton
menuButton
;
private
ScrollableTabSupport
()
{
boolean
opaque
=
tabPane
.
isOpaque
();
Color
bgColor
=
UIManager
.
getColor
(
"TabbedPane.tabAreaBackground"
);
if
(
bgColor
==
null
)
{
bgColor
=
tabPane
.
getBackground
();
}
viewport
=
new
JViewport
();
viewport
.
setName
(
"TabbedPane.scrollableViewport"
);
viewport
.
setScrollMode
(
SIMPLE_SCROLL_MODE
);
viewport
.
setOpaque
(
opaque
);
viewport
.
setBackground
(
bgColor
);
tabPanel
=
new
JPanel
()
{
@Override
public
void
paintComponent
(
Graphics
g
)
{
super
.
paintComponent
(
g
);
DarculaTabbedPaneUI
.
this
.
paintTabArea
(
g
,
tabPane
.
getTabPlacement
(),
tabPane
.
getSelectedIndex
());
}
};
tabPanel
.
setOpaque
(
opaque
);
tabPanel
.
setBackground
(
bgColor
);
viewport
.
setView
(
tabPanel
);
//viewport.addChangeListener(this);
createMenuButton
();
}
private
void
createMenuButton
()
{
if
(
menuButton
!=
null
)
{
tabPane
.
remove
(
menuButton
);
menuButton
.
removeActionListener
(
this
);
}
// TODO: honour tab placement
menuButton
=
new
JButton
(
"0"
);
menuButton
.
addActionListener
(
this
);
tabPane
.
add
(
menuButton
);
}
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
System
.
out
.
printf
(
"Menu click"
);
}
@Override
public
void
stateChanged
(
ChangeEvent
e
)
{
}
}
}
This diff is collapsed.
Click to expand it.
platform/platform-impl/src/com/intellij/internal/ui/ComponentPanelTestAction.java
+
1
-
1
View file @
0f8a72ec
...
...
@@ -59,7 +59,7 @@ public class ComponentPanelTestAction extends DumbAwareAction {
pane
.
addTab
(
"Component Grid"
,
createComponentGridPanel
());
pane
.
addTab
(
"Progress Grid"
,
createProgressGridPanel
());
for
(
int
i
=
1
;
i
<=
2
0
;
i
++)
{
for
(
int
i
=
1
;
i
<=
2
;
i
++)
{
String
title
=
"Blank "
+
i
;
JLabel
label
=
new
JLabel
(
title
);
pane
.
addTab
(
title
,
JBUI
.
Panels
.
simplePanel
(
label
));
...
...
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