|
|
|
@ -14,6 +14,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.image.*;
|
|
|
|
import java.awt.image.*;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
import javax.swing.*;
|
|
|
|
import javax.swing.plaf.*;
|
|
|
|
import javax.swing.plaf.*;
|
|
|
|
@ -83,25 +84,27 @@ public class SIPCommTabbedPaneEnhancedUI
|
|
|
|
private static final String TAB_RIGHT_BG =
|
|
|
|
private static final String TAB_RIGHT_BG =
|
|
|
|
"service.gui.lookandfeel.TAB_RIGHT_BG";
|
|
|
|
"service.gui.lookandfeel.TAB_RIGHT_BG";
|
|
|
|
|
|
|
|
|
|
|
|
public static ComponentUI createUI(JComponent c) {
|
|
|
|
protected final java.util.List<Integer> highlightedTabs
|
|
|
|
|
|
|
|
= new Vector<Integer>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ComponentUI createUI(JComponent c)
|
|
|
|
|
|
|
|
{
|
|
|
|
return new SIPCommTabbedPaneEnhancedUI();
|
|
|
|
return new SIPCommTabbedPaneEnhancedUI();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
|
|
|
protected void paintFocusIndicator(Graphics g, int tabPlacement,
|
|
|
|
Rectangle[] rects, int tabIndex, Rectangle iconRect,
|
|
|
|
Rectangle[] rects, int tabIndex, Rectangle iconRect,
|
|
|
|
Rectangle textRect, boolean isSelected) {
|
|
|
|
Rectangle textRect, boolean isSelected) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Overriden to paint nothing.
|
|
|
|
* Overriden to paint nothing.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
|
|
|
|
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
|
|
|
|
int x, int y, int w, int h, boolean isSelected) {
|
|
|
|
int x, int y, int w, int h, boolean isSelected) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
|
|
|
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
|
|
|
int selectedIndex, int x, int y, int w, int h) {
|
|
|
|
int selectedIndex, int x, int y, int w, int h)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
@ -110,8 +113,8 @@ protected void paintContentBorderTopEdge(Graphics g, int tabPlacement,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
|
|
|
|
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
|
|
|
|
int selectedIndex, int x, int y, int w, int h) {
|
|
|
|
int selectedIndex, int x, int y, int w, int h)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
@ -121,8 +124,8 @@ protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
|
|
|
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
|
|
|
int selectedIndex, int x, int y, int w, int h) {
|
|
|
|
int selectedIndex, int x, int y, int w, int h)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
@ -135,8 +138,8 @@ protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
|
|
|
|
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement,
|
|
|
|
int selectedIndex, int x, int y, int w, int h) {
|
|
|
|
int selectedIndex, int x, int y, int w, int h)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
if (tabPane.getTabCount() < 1)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
@ -170,13 +173,13 @@ private void internalPaintTabBackground(Graphics g, int tabPlacement,
|
|
|
|
BufferedImage leftImg = null;
|
|
|
|
BufferedImage leftImg = null;
|
|
|
|
BufferedImage middleImg = null;
|
|
|
|
BufferedImage middleImg = null;
|
|
|
|
BufferedImage rightImg = null;
|
|
|
|
BufferedImage rightImg = null;
|
|
|
|
|
|
|
|
|
|
|
|
Graphics2D g2 = (Graphics2D) g;
|
|
|
|
Graphics2D g2 = (Graphics2D) g;
|
|
|
|
|
|
|
|
|
|
|
|
AntialiasingManager.activateAntialiasing(g2);
|
|
|
|
AntialiasingManager.activateAntialiasing(g2);
|
|
|
|
|
|
|
|
|
|
|
|
int tabOverlap = 0;
|
|
|
|
int tabOverlap = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (isSelected)
|
|
|
|
if (isSelected)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tabPane.isEnabledAt(tabIndex))
|
|
|
|
if (tabPane.isEnabledAt(tabIndex))
|
|
|
|
@ -210,8 +213,8 @@ private void internalPaintTabBackground(Graphics g, int tabPlacement,
|
|
|
|
|
|
|
|
|
|
|
|
protected void paintText(Graphics g, int tabPlacement, Font font,
|
|
|
|
protected void paintText(Graphics g, int tabPlacement, Font font,
|
|
|
|
FontMetrics metrics, int tabIndex, String title,
|
|
|
|
FontMetrics metrics, int tabIndex, String title,
|
|
|
|
Rectangle textRect, boolean isSelected) {
|
|
|
|
Rectangle textRect, boolean isSelected)
|
|
|
|
|
|
|
|
{
|
|
|
|
g.setFont(font);
|
|
|
|
g.setFont(font);
|
|
|
|
|
|
|
|
|
|
|
|
int titleWidth = SwingUtilities.computeStringWidth(metrics, title);
|
|
|
|
int titleWidth = SwingUtilities.computeStringWidth(metrics, title);
|
|
|
|
@ -220,18 +223,20 @@ protected void paintText(Graphics g, int tabPlacement, Font font,
|
|
|
|
if (isOneActionButtonEnabled()) {
|
|
|
|
if (isOneActionButtonEnabled()) {
|
|
|
|
preferredWidth = calculateTabWidth(tabPlacement, tabIndex, metrics)
|
|
|
|
preferredWidth = calculateTabWidth(tabPlacement, tabIndex, metrics)
|
|
|
|
- WIDTHDELTA - 15;
|
|
|
|
- WIDTHDELTA - 15;
|
|
|
|
|
|
|
|
|
|
|
|
if (isCloseEnabled())
|
|
|
|
if (isCloseEnabled())
|
|
|
|
preferredWidth -= BUTTONSIZE;
|
|
|
|
preferredWidth -= BUTTONSIZE;
|
|
|
|
|
|
|
|
|
|
|
|
if (isMaxEnabled())
|
|
|
|
if (isMaxEnabled())
|
|
|
|
preferredWidth -= BUTTONSIZE;
|
|
|
|
preferredWidth -= BUTTONSIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
preferredWidth = titleWidth;
|
|
|
|
preferredWidth = titleWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
while (titleWidth > preferredWidth) {
|
|
|
|
while (titleWidth > preferredWidth)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (title.endsWith("..."))
|
|
|
|
if (title.endsWith("..."))
|
|
|
|
title = title.substring(0, title.indexOf("...") - 1)
|
|
|
|
title = title.substring(0, title.indexOf("...") - 1)
|
|
|
|
.concat("...");
|
|
|
|
.concat("...");
|
|
|
|
@ -245,29 +250,37 @@ protected void paintText(Graphics g, int tabPlacement, Font font,
|
|
|
|
textRect.width = titleWidth;
|
|
|
|
textRect.width = titleWidth;
|
|
|
|
|
|
|
|
|
|
|
|
View v = getTextViewForTab(tabIndex);
|
|
|
|
View v = getTextViewForTab(tabIndex);
|
|
|
|
if (v != null) {
|
|
|
|
if (v != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
// html
|
|
|
|
// html
|
|
|
|
v.paint(g, textRect);
|
|
|
|
v.paint(g, textRect);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
// plain text
|
|
|
|
// plain text
|
|
|
|
int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
|
|
|
|
int mnemIndex = tabPane.getDisplayedMnemonicIndexAt(tabIndex);
|
|
|
|
|
|
|
|
|
|
|
|
if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex)) {
|
|
|
|
if (tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex))
|
|
|
|
|
|
|
|
{
|
|
|
|
if (isSelected)
|
|
|
|
if (isSelected)
|
|
|
|
g.setColor(whiteColor);
|
|
|
|
g.setColor(whiteColor);
|
|
|
|
else {
|
|
|
|
else
|
|
|
|
if (this.isTabHighlighted(tabIndex)) {
|
|
|
|
{
|
|
|
|
g.setColor(
|
|
|
|
if (this.isTabHighlighted(tabIndex))
|
|
|
|
UIManager.getColor("TabbedPane.tabTitleHighlight"));
|
|
|
|
{
|
|
|
|
} else
|
|
|
|
g.setColor(new Color(UtilActivator.getResources()
|
|
|
|
|
|
|
|
.getColor("service.gui.TAB_TITLE_HIGHLIGHT")));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
g.setColor(tabPane.getForegroundAt(tabIndex));
|
|
|
|
g.setColor(tabPane.getForegroundAt(tabIndex));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BasicGraphicsUtils
|
|
|
|
BasicGraphicsUtils
|
|
|
|
.drawStringUnderlineCharAt(g, title, mnemIndex,
|
|
|
|
.drawString(g, title, mnemIndex,
|
|
|
|
textRect.x, textRect.y + metrics.getAscent());
|
|
|
|
textRect.x, textRect.y + metrics.getAscent());
|
|
|
|
|
|
|
|
}
|
|
|
|
} else { // tab disabled
|
|
|
|
else
|
|
|
|
|
|
|
|
{ // tab disabled
|
|
|
|
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
|
|
|
|
g.setColor(tabPane.getBackgroundAt(tabIndex).brighter());
|
|
|
|
BasicGraphicsUtils
|
|
|
|
BasicGraphicsUtils
|
|
|
|
.drawStringUnderlineCharAt(g, title, mnemIndex,
|
|
|
|
.drawStringUnderlineCharAt(g, title, mnemIndex,
|
|
|
|
@ -282,18 +295,21 @@ protected void paintText(Graphics g, int tabPlacement, Font font,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected class ScrollableTabButton extends
|
|
|
|
protected class ScrollableTabButton extends
|
|
|
|
SIPCommTabbedPaneUI.ScrollableTabButton {
|
|
|
|
SIPCommTabbedPaneUI.ScrollableTabButton
|
|
|
|
|
|
|
|
{
|
|
|
|
public ScrollableTabButton(int direction) {
|
|
|
|
public ScrollableTabButton(int direction)
|
|
|
|
|
|
|
|
{
|
|
|
|
super(direction);
|
|
|
|
super(direction);
|
|
|
|
setRolloverEnabled(true);
|
|
|
|
setRolloverEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Dimension getPreferredSize() {
|
|
|
|
public Dimension getPreferredSize()
|
|
|
|
|
|
|
|
{
|
|
|
|
return new Dimension(16, calculateMaxTabHeight(0));
|
|
|
|
return new Dimension(16, calculateMaxTabHeight(0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) {
|
|
|
|
public void paint(Graphics g)
|
|
|
|
|
|
|
|
{
|
|
|
|
Color origColor;
|
|
|
|
Color origColor;
|
|
|
|
boolean isPressed, isRollOver, isEnabled;
|
|
|
|
boolean isPressed, isRollOver, isEnabled;
|
|
|
|
int w, h, size;
|
|
|
|
int w, h, size;
|
|
|
|
@ -377,22 +393,48 @@ public void paint(Graphics g) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected SIPCommTabbedPaneUI.ScrollableTabButton createScrollableTabButton(
|
|
|
|
protected SIPCommTabbedPaneUI.ScrollableTabButton createScrollableTabButton(
|
|
|
|
int direction) {
|
|
|
|
int direction)
|
|
|
|
|
|
|
|
{
|
|
|
|
return new ScrollableTabButton(direction);
|
|
|
|
return new ScrollableTabButton(direction);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected int calculateTabWidth(int tabPlacement, int tabIndex,
|
|
|
|
protected int calculateTabWidth(int tabPlacement, int tabIndex,
|
|
|
|
FontMetrics metrics) {
|
|
|
|
FontMetrics metrics)
|
|
|
|
|
|
|
|
{
|
|
|
|
int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
|
|
|
|
int width = super.calculateTabWidth(tabPlacement, tabIndex, metrics);
|
|
|
|
|
|
|
|
|
|
|
|
if (isOneActionButtonEnabled())
|
|
|
|
if (isOneActionButtonEnabled())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(width > PREFERRED_WIDTH)
|
|
|
|
if(width > PREFERRED_WIDTH)
|
|
|
|
width = PREFERRED_WIDTH;
|
|
|
|
width = PREFERRED_WIDTH;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return width + WIDTHDELTA;
|
|
|
|
return width + WIDTHDELTA;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void tabAddHightlight(int tabIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.highlightedTabs.add(tabIndex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void tabRemoveHighlight(int tabIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Iterator<Integer> highlightedIter = highlightedTabs.iterator();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (highlightedIter.hasNext())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (highlightedIter.next().intValue() == tabIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
highlightedIter.remove();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isTabHighlighted(int tabIndex)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return highlightedTabs.contains(tabIndex);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|