diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java index 157a83933..55bb8db04 100644 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneEnhancedUI.java @@ -15,16 +15,22 @@ import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; +import java.awt.Image; import java.awt.Rectangle; import java.awt.geom.GeneralPath; +import java.awt.image.BufferedImage; import javax.swing.JComponent; +import javax.swing.SwingUtilities; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicGraphicsUtils; import javax.swing.text.View; +import sun.security.action.GetBooleanAction; + import net.java.sip.communicator.impl.gui.main.utils.AntialiasingManager; import net.java.sip.communicator.impl.gui.main.utils.Constants; +import net.java.sip.communicator.impl.gui.main.utils.ImageLoader; /** * This UI displays a different interface, which is independent from the look @@ -45,6 +51,11 @@ public class CloseTabPaneEnhancedUI extends CloseTabPaneUI { private static final Color lightWhite = new Color(200, 200, 200, 50); private static final Color selectedColor = new Color(20, 62, 123); + + private static Image TAB_BACKGROUND = ImageLoader.getImage(ImageLoader.TAB_BG); + + private static Image CLOSABLE_TAB_BACKGROUND + = ImageLoader.getImage(ImageLoader.CLOSABLE_TAB_BG); public static ComponentUI createUI(JComponent c) { return new CloseTabPaneEnhancedUI(); @@ -55,34 +66,12 @@ protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle textRect, boolean isSelected) { } + /** + * Overriden to paint nothing. + */ protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - - Graphics2D g2 = (Graphics2D)g; - - g2.setColor(Constants.CONTACTPANEL_LINES_COLOR); - - - GeneralPath border = new GeneralPath(); - - border.moveTo(x , y + h - 1); - border.lineTo(x, y + 5); - border.curveTo(x, y + 5, x, y, x + 5, y); - border.lineTo(x + w - 7, y); - border.curveTo(x + w - 7, y, x + w - 2, y, x + w - 2, y + 5); - border.lineTo(x + w - 2, y + h - 1); - - /* - border.moveTo(x , y + h - 1); - border.lineTo(x, y + 5); - border.curveTo(x, y + 5, x, y, x + 5, y); - border.lineTo(x + w - 28, y); - border.curveTo(x + w - 28, y, - x + w - 36, (y + h)/2, - x + w - 15, y + h - 2); - */ - g2.draw(border); } protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, @@ -138,79 +127,40 @@ protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) { - if (isSelected) { - - GradientPaint gradient; - - if (tabPane.isEnabledAt(tabIndex)) { - gradient = new GradientPaint(w/2, y, selectedColor, - w/2, h, lightBlue); - - } else { - gradient = new GradientPaint(w/2, y, Color.GRAY, w/2, h, - lightWhite); - } - - Graphics2D g2 = (Graphics2D) g; - - AntialiasingManager.activateAntialiasing(g2); - - g2.setPaint(gradient); - - GeneralPath border = new GeneralPath(); - - border.moveTo(x , y + h); - border.lineTo(x, y + 5); - border.curveTo(x, y + 5, x, y, x + 5, y); - border.lineTo(x + w - 7, y); - border.curveTo(x + w - 7, y, x + w - 2, y, x + w - 2, y + 5); - border.lineTo(x + w - 2, y + h); - - /* - border.moveTo(x , y + h - 1); - border.lineTo(x, y + 5); - border.curveTo(x, y + 5, x, y, x + 5, y); - border.lineTo(x + w - 28, y); - border.curveTo(x + w - 28, y, - x + w - 20, (y + h)/2, - x + w - 15, y + h - 2); - */ - - g2.fill(border); - } - else{ - - GradientPaint gradient; - - gradient = new GradientPaint(w/2, y, - Constants.CONTACTPANEL_LINES_COLOR, w/2, h, - Constants.CONTACTPANEL_MOVER_END_COLOR); - - Graphics2D g2 = (Graphics2D) g; - - AntialiasingManager.activateAntialiasing(g2); - - g2.setPaint(gradient); - - GeneralPath border = new GeneralPath(); - - border.moveTo(x , y + h); - border.lineTo(x, y + 5); - border.curveTo(x, y + 5, x, y, x + 5, y); - border.lineTo(x + w - 7, y); - border.curveTo(x + w - 7, y, x + w - 2, y, x + w - 2, y + 5); - border.lineTo(x + w - 2, y + h); - /* - border.moveTo(x , y + h - 1); - border.lineTo(x, y + 5); - border.curveTo(x, y + 5, x, y, x + 5, y); - border.lineTo(x + w - 28, y); - border.curveTo(x + w - 28, y, - x + w - 20, (y + h)/2, - x + w - 15, y + h - 2); - */ - - g2.fill(border); + Image img= null; + + Graphics2D g2 = (Graphics2D) g; + + AntialiasingManager.activateAntialiasing(g2); + + if(!isOneActionButtonEnabled()){ + if (isSelected) { + + if (tabPane.isEnabledAt(tabIndex)) { + img = ImageLoader.getImage(ImageLoader.SELECTED_TAB_BG); + } else { + img = ImageLoader.getImage(ImageLoader.TAB_BG); + } + + g2.drawImage(img, x, y, null); + } + else{ + img = ImageLoader.getImage(ImageLoader.TAB_BG); + + g2.drawImage(img, x, y, null); + } + } + else{ + if(isSelected){ + img = ImageLoader.getImage(ImageLoader.SELECTED_CLOSABLE_TAB_BG); + + g2.drawImage(img, x, y, null); + } + else{ + img = ImageLoader.getImage(ImageLoader.CLOSABLE_TAB_BG); + + g2.drawImage(img, x, y, null); + } } } @@ -220,6 +170,28 @@ protected void paintText(Graphics g, int tabPlacement, Font font, g.setFont(font); + int titleWidth = SwingUtilities.computeStringWidth(metrics, title); + + if(isOneActionButtonEnabled()){ + int preferredWidth = CLOSABLE_TAB_BACKGROUND.getWidth(null) + - 2*WIDTHDELTA - 12; + if(isCloseEnabled()) + preferredWidth -= BUTTONSIZE; + + if(isMaxEnabled()) + preferredWidth -= BUTTONSIZE; + + while(titleWidth > preferredWidth){ + if(title.endsWith("...")) + title = title.substring(0, title.indexOf("...") - 1).concat("..."); + else + title = title.substring(0, title.length() - 3).concat("..."); + + titleWidth = SwingUtilities.computeStringWidth(metrics, title); + textRect.width = titleWidth; + } + } + View v = getTextViewForTab(tabIndex); if (v != null) { // html @@ -352,4 +324,15 @@ protected CloseTabPaneUI.ScrollableTabButton createScrollableTabButton( return new ScrollableTabButton(direction); } + protected int calculateTabWidth(int tabPlacement, int tabIndex, + FontMetrics metrics) { + int width = 0; + if (!isOneActionButtonEnabled()) + width = TAB_BACKGROUND.getWidth(null); + else { + width = CLOSABLE_TAB_BACKGROUND.getWidth(null); + } + + return width - 14; + } } \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java index 40ef5cd07..bd2e5d78d 100644 --- a/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java +++ b/src/net/java/sip/communicator/impl/gui/main/customcontrols/tabbedPane/CloseTabPaneUI.java @@ -114,9 +114,9 @@ public class CloseTabPaneUI extends BasicTabbedPaneUI { private static final int PRESSED = 2; - protected static final int BUTTONSIZE = 15; + public static final int BUTTONSIZE = 15; - protected static final int WIDTHDELTA = 5; + public static final int WIDTHDELTA = 10; private static final Border PRESSEDBORDER = new SoftBevelBorder( SoftBevelBorder.LOWERED); @@ -231,9 +231,9 @@ private void setPopupMenu() { protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics) { - int delta = 2; + int delta = 5; if (!isOneActionButtonEnabled()) - delta += 6; + delta += 5; else { if (isCloseButtonEnabled) delta += BUTTONSIZE + WIDTHDELTA; @@ -247,7 +247,7 @@ protected int calculateTabWidth(int tabPlacement, int tabIndex, protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) { - return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight); + return super.calculateTabHeight(tabPlacement, tabIndex, fontHeight + 4); } protected void layoutLabel(int tabPlacement, FontMetrics metrics, @@ -264,12 +264,12 @@ protected void layoutLabel(int tabPlacement, FontMetrics metrics, SwingUtilities.layoutCompoundLabel((JComponent) tabPane, metrics, title, icon, SwingUtilities.CENTER, SwingUtilities.LEFT, SwingUtilities.CENTER, SwingUtilities.CENTER, tabRect, - iconRect, textRect, textIconGap); + iconRect, textRect, 5); tabPane.putClientProperty("html", null); - iconRect.x = tabRect.x + 8; - textRect.x = iconRect.x + iconRect.width + textIconGap; + iconRect.x = tabRect.x + 5; + textRect.x = iconRect.x + iconRect.width + 5; } protected MouseListener createMouseListener() { @@ -662,7 +662,7 @@ protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, } else if (isOver || isSelected) { int dx = tabRect.x + tabRect.width - BUTTONSIZE - WIDTHDELTA; - int dy = (tabRect.y + tabRect.height) / 2 - 6; + int dy = (tabRect.y + tabRect.height) / 2 - 7; if (isCloseButtonEnabled) paintCloseIcon(g2, dx, dy, isOver); diff --git a/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java b/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java index 433b00109..8e068c117 100755 --- a/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java +++ b/src/net/java/sip/communicator/impl/gui/main/utils/Constants.java @@ -162,33 +162,7 @@ public class Constants { mainStatusSet.put(Constants.INVISIBLE_STATUS, ImageLoader.getImage(ImageLoader.USER_ONLINE_ICON)); } - - /** - * Defines the priority of the statuses. The priority of statuses is used when detecting the - * current status of a MetaContact, containing more than one protocol contacts. The status - * in the table has the highest priority. - */ - public static final LinkedList statusPriorityTable = new LinkedList(); - static{ - statusPriorityTable.addLast(Constants.CHAT_STATUS); - statusPriorityTable.addLast(Constants.ONLINE_STATUS); - statusPriorityTable.addLast(Constants.INVISIBLE_STATUS); - statusPriorityTable.addLast(Constants.OCCUPIED_STATUS); - statusPriorityTable.addLast(Constants.DND_STATUS); - statusPriorityTable.addLast(Constants.AWAY_STATUS); - statusPriorityTable.addLast(Constants.NA_STATUS); - statusPriorityTable.addLast(Constants.OFFLINE_STATUS); - } - /** - * Returns the priority of the given status according to the statusPriorityTable. - * @param status The given status. - * @return The priority of the given status according to the statusPriorityTable. - */ - public static int getPriority(PresenceStatus status){ - return Constants.statusPriorityTable.indexOf(status); - } - /* * ==================================================== * ------------------------ PROTOCOL NAMES ------------------------------- diff --git a/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java index bc174edde..eefb1a910 100644 --- a/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/main/utils/ImageLoader.java @@ -153,7 +153,19 @@ public class ImageLoader { public static final ImageID BOTTOM_ARROW_ROLLOVER_ICON = new ImageID("BOTTOM_ARROW_ROLLOVER_ICON"); + + public static final ImageID TAB_BG + = new ImageID("TAB_BG"); + + public static final ImageID SELECTED_TAB_BG + = new ImageID("SELECTED_TAB_BG"); + + public static final ImageID CLOSABLE_TAB_BG + = new ImageID("CLOSABLE_TAB_BG"); + public static final ImageID SELECTED_CLOSABLE_TAB_BG + = new ImageID("SELECTED_CLOSABLE_TAB_BG"); + /////////////////////// Edit Text Toolbar icons ////////////////////////// public static final ImageID ALIGN_LEFT_BUTTON diff --git a/src/net/java/sip/communicator/impl/gui/main/utils/images.properties b/src/net/java/sip/communicator/impl/gui/main/utils/images.properties index 2089f171b..322faa452 100644 --- a/src/net/java/sip/communicator/impl/gui/main/utils/images.properties +++ b/src/net/java/sip/communicator/impl/gui/main/utils/images.properties @@ -137,4 +137,10 @@ USER_FFC_ICON=net/java/sip/communicator/impl/gui/resources/common/statusicons/fr USER_OCCUPIED_ICON=net/java/sip/communicator/impl/gui/resources/common/statusicons/occupied.png CLOSE_TAB_ICON=net/java/sip/communicator/impl/gui/resources/buttons/closeTab.png -CLOSE_TAB_SELECTED_ICON=net/java/sip/communicator/impl/gui/resources/buttons/closeTabSelected.png \ No newline at end of file +CLOSE_TAB_SELECTED_ICON=net/java/sip/communicator/impl/gui/resources/buttons/closeTabSelected.png + +SELECTED_TAB_BG=net/java/sip/communicator/impl/gui/resources/common/notebook3.png +TAB_BG=net/java/sip/communicator/impl/gui/resources/common/notebook2.png + +SELECTED_CLOSABLE_TAB_BG=net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png +CLOSABLE_TAB_BG=net/java/sip/communicator/impl/gui/resources/common/closableTab.png \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/resources/common/closableTab.png b/src/net/java/sip/communicator/impl/gui/resources/common/closableTab.png new file mode 100644 index 000000000..e3710a198 Binary files /dev/null and b/src/net/java/sip/communicator/impl/gui/resources/common/closableTab.png differ diff --git a/src/net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png b/src/net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png new file mode 100644 index 000000000..6a6610732 Binary files /dev/null and b/src/net/java/sip/communicator/impl/gui/resources/common/closableTabSelected.png differ