Tries to better support the system preferences with respect to fonts. The HTMLEditorKit used to display the conversation in the chat window still wouldn't always use the right font size but I don't see regressions.

cusax-fix
Lyubomir Marinov 17 years ago
parent 3a233b9450
commit d7d0c7f3b3

@ -1,71 +1,64 @@
h1
{
background-color:#c6d0e1;
margin:0px;
text-align:center;
font-weight:bold;
font-size:12
background-color: #c6d0e1;
margin: 0px;
text-align: center;
font-weight: bold;
font-size: 100%;
}
h2
{
margin:0px;
font-family:Verdana;
font-size:12;
color:#ef7b1e
margin: 0px;
font-size: 100%;
color: #ef7b1e;
}
h3
{
margin:0px;
font-family:Verdana;
font-size:12;
color:#2e538b
margin: 0px;
font-size: 100%;
color: #2e538b;
}
h4
{
margin:0px;
font-family:Verdana;
font-size:12;
font-weight:bold;
color:#FFC875
margin: 0px;
font-size: 100%;
font-weight: bold;
color: #FFC875;
}
h5
{
margin:0px;
font-family:Verdana;
font-size:12;
font-weight:bold;
color:#CC0000
margin: 0px;
font-size: 100%;
font-weight: bold;
color: #CC0000;
}
h6
{
margin:0px;
font-family:Verdana;
font-size:12;
font-weight:bold;
color:#990000
margin: 0px;
font-size: 100%;
font-weight: bold;
color: #990000;
}
p
{
margin:0px;
font-family:Verdana;
font-size:12;
font-weight:bold;
color:#62BD80
margin: 0px;
font-size: 100%;
font-weight: bold;
color: #62BD80;
}
div
{
font-family:Verdana;
font-size:12;
color:#000000
font-size: 100%;
color: #000000;
}
h7
{
background-color:#FFF4AB
}
background-color: #FFF4AB;
}

@ -739,8 +739,7 @@ private void setDefaultThemePack()
boolean lafIsSet = false;
if ((laf != null)
&& !laf
.equals(UIManager.getCrossPlatformLookAndFeelClassName()))
&& !laf.equals(UIManager.getCrossPlatformLookAndFeelClassName()))
{
try
{
@ -749,23 +748,17 @@ private void setDefaultThemePack()
lafIsSet = true;
UIDefaults uiDefaults = UIManager.getDefaults();
// Workaround for bug 6396936 (http://bugs.sun.com): WinL&F :
// font for text area is incorrect.
if (osName.startsWith("Windows"))
{
uiDefaults.put( "TextArea.font",
uiDefaults.get("TextField.font"));
}
fixWindowsUIDefaults(uiDefaults);
// Workaround for SC issue #516
// "GNOME SCScrollPane has rounded and rectangular borders"
if(laf.equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")
|| laf
.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel"))
if (laf.equals("com.sun.java.swing.plaf.gtk.GTKLookAndFeel")
|| laf.equals("com.sun.java.swing.plaf.motif.MotifLookAndFeel"))
{
UIDefaults metalDefaults = (new javax.swing.plaf.metal
.MetalLookAndFeel()).getDefaults();
uiDefaults.put("ScrollPaneUI",
metalDefaults.get("ScrollPaneUI"));
uiDefaults.put(
"ScrollPaneUI",
new javax.swing.plaf.metal.MetalLookAndFeel()
.getDefaults().get("ScrollPaneUI"));
}
}
catch (ClassNotFoundException ex)
@ -819,6 +812,72 @@ private void setDefaultThemePack()
}
}
private void fixWindowsUIDefaults(UIDefaults uiDefaults)
{
/*
* Windows actually uses different fonts for the controls in windows and
* the controls in dialogs. Unfortunately, win.defaultGUI.font may not
* be the font Windows will use for controls in windows but the one to
* be used for dialogs. And win.messagebox.font will be the font for
* windows but the L&F will use it for OptionPane which in turn should
* rather use the font for dialogs. So swap the meanings of the two to
* get standard fonts in the windows while compromizing that dialogs may
* appear in it as well (if the dialogs are created as non-OptionPanes
* and in this case SIP Communicator will behave as Mozilla Firfox and
* Eclipse with respect to using the window font for the dialogs).
*/
Toolkit toolkit = Toolkit.getDefaultToolkit();
Object menuFont = toolkit.getDesktopProperty("win.menu.font");
Object messageboxFont
= toolkit.getDesktopProperty("win.messagebox.font");
if ((messageboxFont != null) && messageboxFont.equals(menuFont))
{
Object defaultGUIFont
= toolkit.getDesktopProperty("win.defaultGUI.font");
if ((defaultGUIFont != null)
&& !defaultGUIFont.equals(messageboxFont))
{
Object messageFont = uiDefaults.get("OptionPane.font");
Object controlFont = uiDefaults.get("Panel.font");
if ((messageFont != null) && !messageFont.equals(controlFont))
{
uiDefaults.put("OptionPane.font", controlFont);
uiDefaults.put("OptionPane.messageFont", controlFont);
uiDefaults.put("OptionPane.buttonFont", controlFont);
uiDefaults.put("Button.font", messageFont);
uiDefaults.put("CheckBox.font", messageFont);
uiDefaults.put("ComboBox.font", messageFont);
uiDefaults.put("EditorPane.font", messageFont);
uiDefaults.put("FormattedTextField.font", messageFont);
uiDefaults.put("Label.font", messageFont);
uiDefaults.put("List.font", messageFont);
uiDefaults.put("RadioButton.font", messageFont);
uiDefaults.put("Panel.font", messageFont);
uiDefaults.put("PasswordField.font", messageFont);
uiDefaults.put("ProgressBar.font", messageFont);
uiDefaults.put("ScrollPane.font", messageFont);
uiDefaults.put("Slider.font", messageFont);
uiDefaults.put("Spinner.font", messageFont);
uiDefaults.put("TabbedPane.font", messageFont);
uiDefaults.put("Table.font", messageFont);
uiDefaults.put("TableHeader.font", messageFont);
uiDefaults.put("TextField.font", messageFont);
uiDefaults.put("TextPane.font", messageFont);
uiDefaults.put("TitledBorder.font", messageFont);
uiDefaults.put("ToggleButton.font", messageFont);
uiDefaults.put("Tree.font", messageFont);
uiDefaults.put("Viewport.font", messageFont);
}
}
}
// Workaround for bug 6396936 (http://bugs.sun.com): WinL&F : font for
// text area is incorrect.
uiDefaults.put("TextArea.font", uiDefaults.get("TextField.font"));
}
/**
* Notifies all plugin containers of a <tt>PluginComponent</tt>
* registration.

@ -32,11 +32,11 @@ public StyledHTMLEditorPane()
this.setEditorKitForContentType("text/html", editorKit);
this.setEditorKit(editorKit);
this.setDocument(document);
Constants.loadSimpleStyle(document.getStyleSheet());
putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
Constants.loadSimpleStyle(document.getStyleSheet(), getFont());
}
public void appendToEnd(String text)
{
Element root = document.getDefaultRootElement();

@ -33,12 +33,7 @@ public class TitlePanel
*/
public TitlePanel()
{
super(new FlowLayout(FlowLayout.CENTER));
this.setPreferredSize(new Dimension(0, 30));
this.titleLabel.setFont(this.getFont().deriveFont(Font.BOLD, 14));
this(null);
}
/**
@ -51,11 +46,13 @@ public TitlePanel(String title)
{
super(new FlowLayout(FlowLayout.CENTER));
this.titleLabel.setFont(this.getFont().deriveFont(Font.BOLD, 14));
Font font = getFont();
titleLabel.setFont(font.deriveFont(Font.BOLD, font.getSize() + 2));
this.titleLabel.setText(title);
this.add(titleLabel);
if (title != null)
setTitleText(title);
else
setPreferredSize(new Dimension(0, 30));
}
/**
@ -67,16 +64,18 @@ public void paintComponent(Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
int width = getWidth();
int height = getHeight();
GradientPaint p =
new GradientPaint(this.getWidth() / 2, 0,
gradientStartColor,
this.getWidth() / 2,
getHeight(),
gradientEndColor);
new GradientPaint(width / 2,
0,
gradientStartColor,
width / 2,
height,
gradientEndColor);
g2.setPaint(p);
g2.fillRoundRect(0, 0, this.getWidth(), getHeight(), 10, 10);
g2.fillRoundRect(0, 0, width, height, 10, 10);
}
/**

@ -12,7 +12,7 @@
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@ -51,7 +51,8 @@ public AccountRegSummaryPage(AccountRegWizardContainerImpl wizardContainer)
JLabel pageTitleLabel = new JLabel(
GuiActivator.getResources().getI18NString("service.gui.SUMMARY"),
JLabel.CENTER);
pageTitleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD, 18f));
Font font = getFont();
pageTitleLabel.setFont(font.deriveFont(Font.BOLD, font.getSize() + 6));
JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));
mainPanel.add(pageTitleLabel, BorderLayout.NORTH);

@ -103,7 +103,10 @@ public ChatConversationPanel(ChatConversationContainer chatContainer)
this.chatEditorPane.setDocument(document);
Constants.loadSimpleStyle(document.getStyleSheet());
chatEditorPane.putClientProperty(
JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
Constants.loadSimpleStyle(
document.getStyleSheet(), chatEditorPane.getFont());
this.chatEditorPane.addHyperlinkListener(this);
this.chatEditorPane.addMouseListener(this);
@ -926,7 +929,8 @@ public void copyConversation()
public void clear()
{
this.document = (HTMLDocument) editorKit.createDefaultDocument();
Constants.loadSimpleStyle(document.getStyleSheet());
Constants.loadSimpleStyle(
document.getStyleSheet(), chatEditorPane.getFont());
}
/**

@ -163,18 +163,15 @@ public Image createTransportStatusImage(ChatTransport chatTransport)
Image img;
if(index > 0) {
BufferedImage buffImage = new BufferedImage(
22, 16, BufferedImage.TYPE_INT_ARGB);
BufferedImage buffImage
= new BufferedImage(22, 16, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D)buffImage.getGraphics();
AlphaComposite ac =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
AntialiasingManager.activateAntialiasing(g);
g.setColor(Color.DARK_GRAY);
g.setFont(Constants.FONT.deriveFont(Font.BOLD, 9));
g.drawImage(statusImage, 0, 0, null);
g.setComposite(ac);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
g.drawString(Integer.toString(index+1), 14, 8);
img = buffImage;

@ -71,7 +71,10 @@ public ChatWritePanel(ChatPanel panel)
this.chatPanel = panel;
this.editorPane.setContentType("text/html");
this.editorPane.setFont(Constants.FONT);
this.editorPane.putClientProperty(
JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
this.editorPane.setCaretPosition(0);
this.editorPane.setEditorKit(new SIPCommHTMLEditorKit());
this.editorPane.getDocument().addUndoableEditListener(this);

@ -85,7 +85,7 @@ public ChatInviteDialog (ChatPanel chatPanel)
infoTextArea.setText(GuiActivator.getResources()
.getI18NString("service.gui.INVITE_CONTACT_MSG"));
infoTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD, 12f));
infoTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD));
infoTextArea.setLineWrap(true);
infoTextArea.setOpaque(false);
infoTextArea.setWrapStyleWord(true);

@ -122,7 +122,7 @@ public InvitationReceivedDialog (ConferenceChatManager multiUserChatManager,
this.dataPanel.add(invitationReasonTextArea, BorderLayout.CENTER);
}
this.infoTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD, 12f));
this.infoTextArea.setFont(Constants.FONT.deriveFont(Font.BOLD));
this.infoTextArea.setLineWrap(true);
this.infoTextArea.setOpaque(false);
this.infoTextArea.setWrapStyleWord(true);

@ -14,7 +14,6 @@
import net.java.sip.communicator.impl.gui.customcontrols.*;
import net.java.sip.communicator.impl.gui.lookandfeel.*;
import net.java.sip.communicator.impl.gui.utils.*;
/**
* The <tt>DatesPanel</tt> contains the list of history dates for a contact.
*
@ -24,7 +23,6 @@ public class DatesPanel
extends SCScrollPane
implements ListSelectionListener
{
private JList datesList = new JList();
private DefaultListModel listModel = new DefaultListModel();
@ -52,7 +50,7 @@ public DatesPanel(HistoryWindow historyWindow)
this.datesList.setCellRenderer(renderer);
this.datesList.setFont(Constants.FONT.deriveFont(Font.BOLD));
this.datesList.setFont(datesList.getFont().deriveFont(Font.BOLD));
this.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createEmptyBorder(3, 3, 3, 0),

@ -43,9 +43,9 @@ public class ConfigFormListCellRenderer
private static final Color SELECTED_START_COLOR
= new Color(209, 212, 225);
private JLabel textLabel = new JLabel();
private final JLabel textLabel = new JLabel();
private JLabel iconLabel = new JLabel();
private final JLabel iconLabel = new JLabel();
private boolean isSelected = false;
@ -55,23 +55,18 @@ public class ConfigFormListCellRenderer
public ConfigFormListCellRenderer()
{
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 5, 3));
this.setLayout(new BorderLayout(0, 0));
this.setOpaque(true);
this.setPreferredSize(new Dimension(100, 65));
this.setLayout(new BorderLayout(0, 0));
this.setBorder(BorderFactory.createEmptyBorder(3, 3, 5, 3));
this.textLabel.setFont(this.getFont().deriveFont(Font.BOLD, 10));
Font font = getFont();
this.textLabel.setFont(font.deriveFont(Font.BOLD, font.getSize() - 2));
this.iconLabel.setHorizontalAlignment(JLabel.CENTER);
this.textLabel.setHorizontalAlignment(JLabel.CENTER);
this.add(iconLabel, BorderLayout.CENTER);
this.add(textLabel, BorderLayout.SOUTH);
}

@ -59,100 +59,74 @@ public ActionMenuPanel()
this.setOpaque(false);
this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
this.initListeners();
SIPCommButton addContactButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_ADD_ICON));
SIPCommButton optionsButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_CONFIGURE_ICON));
SIPCommButton showOfflineButton;
boolean isShowOffline = ConfigurationManager.isShowOffline();
if (isShowOffline)
showOfflineButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_HIDE_OFFLINE_ICON));
else
showOfflineButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_SHOW_OFFLINE_ICON));
SIPCommButton soundButton;
boolean isMute = GuiActivator.getAudioNotifier().isMute();
if (isMute)
soundButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_SOUND_ON_ICON));
else
soundButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_SOUND_OFF_ICON));
SIPCommButton myChatRoomsButton = new SIPCommButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_MY_CHAT_ROOMS_ICON));
addContactButton.addActionListener(this);
optionsButton.addActionListener(this);
showOfflineButton.addActionListener(this);
soundButton.addActionListener(this);
myChatRoomsButton.addActionListener(this);
addContactButton.setName("addContact");
optionsButton.setName("options");
showOfflineButton.setName("showOffline");
soundButton.setName("sound");
myChatRoomsButton.setName("chatRooms");
JPanel addContactPanel
= createMoreActionsButtonPanel(addContactButton, "Contacts");
JPanel configPanel
= createMoreActionsButtonPanel(optionsButton, "Options");
JPanel showOfflinePanel
= createMoreActionsButtonPanel(showOfflineButton, "Show/Hide");
JPanel soundPanel
= createMoreActionsButtonPanel(soundButton, "Sound");
JPanel myChatRoomsPanel
= createMoreActionsButtonPanel(myChatRoomsButton, "Chatrooms");
this.initListeners();
this.add(addContactPanel);
this.add(configPanel);
this.add(showOfflinePanel);
this.add(soundPanel);
this.add(myChatRoomsPanel);
addMoreActionsButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_ADD_ICON),
"Contacts",
"addContact");
addMoreActionsButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_CONFIGURE_ICON),
"Options",
"options");
addMoreActionsButton(
ImageLoader.getImage(
ConfigurationManager.isShowOffline()
? ImageLoader.QUICK_MENU_HIDE_OFFLINE_ICON
: ImageLoader.QUICK_MENU_SHOW_OFFLINE_ICON),
"Show/Hide",
"showOffline");
addMoreActionsButton(
ImageLoader.getImage(
GuiActivator.getAudioNotifier().isMute()
? ImageLoader.QUICK_MENU_SOUND_ON_ICON
: ImageLoader.QUICK_MENU_SOUND_OFF_ICON),
"Sound",
"sound");
addMoreActionsButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_MY_CHAT_ROOMS_ICON),
"Chatrooms",
"chatRooms");
this.initPluginComponents();
}
private JPanel createMoreActionsButtonPanel(JButton button,
String buttonText)
private SIPCommButton addMoreActionsButton(Image bgImage,
String text,
String name)
{
JLabel buttonLabel = new JLabel(buttonText);
TransparentPanel buttonPanel = new TransparentPanel();
buttonPanel.setPreferredSize(new Dimension(60, 60));
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
buttonLabel.setForeground(Color.WHITE);
buttonLabel.setFont(buttonLabel.getFont().deriveFont(9f));
buttonLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
SIPCommButton button = new SIPCommButton(bgImage);
if (name != null)
{
button.setName(name);
button.addActionListener(this);
}
button.setAlignmentX(Component.CENTER_ALIGNMENT);
button.setToolTipText(buttonText);
button.setToolTipText(text);
// Windows defaults to a non-transparent button background.
if (setButtonContentAreaFilled)
button.setContentAreaFilled(false);
JLabel buttonLabel = new JLabel(text);
buttonLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
buttonLabel.setForeground(Color.WHITE);
Font font = buttonLabel.getFont();
buttonLabel.setFont(
font.deriveFont(font.getStyle(), font.getSize() - 3));
JPanel buttonPanel = new TransparentPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
buttonPanel.setPreferredSize(new Dimension(60, 60));
buttonPanel.add(button);
buttonPanel.add(buttonLabel);
buttonPanel.doLayout();
return buttonPanel;
add(buttonPanel);
return button;
}
public void paintComponent(Graphics g)
@ -267,7 +241,7 @@ private void initListeners()
private void initPluginComponents()
{
// Search for plugin components registered through the OSGI bundle
// Search for plugin components registered through the OSGI bundle
// context.
ServiceReference[] serRefs = null;
@ -283,10 +257,10 @@ private void initPluginComponents()
if (serRefs != null)
{
for (int i = 0; i < serRefs.length; i ++)
for (ServiceReference serRef : serRefs)
{
FavoritesButton c = (FavoritesButton) GuiActivator
.bundleContext.getService(serRefs[i]);;
FavoritesButton c = (FavoritesButton)
GuiActivator.bundleContext.getService(serRef);
addPluginComponent(c);
}
@ -295,20 +269,18 @@ private void initPluginComponents()
private void addPluginComponent(final FavoritesButton c)
{
SIPCommButton cButton = new SIPCommButton(
ImageLoader.getBytesInImage(c.getImage()));
SIPCommButton button
= addMoreActionsButton(
ImageLoader.getBytesInImage(c.getImage()),
c.getText(),
null);
JPanel cPanel = createMoreActionsButtonPanel(cButton,
c.getText());
cButton.addActionListener(new ActionListener()
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
c.actionPerformed();
}
});
this.add(cPanel);
}
}

@ -193,7 +193,7 @@ private void init()
.getI18NString("service.gui.SELECT_ACCOUNT"));
infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
infoLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
infoLabel.setFont(infoLabel.getFont().deriveFont(Font.BOLD));
this.addSubcontactMenu.add(infoLabel);
this.addSubcontactMenu.addSeparator();
@ -226,7 +226,7 @@ private void init()
.getI18NString("service.gui.SELECT_GROUP"));
infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
infoLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
infoLabel.setFont(infoLabel.getFont().deriveFont(Font.BOLD));
this.moveToMenu.add(infoLabel);
this.moveToMenu.addSeparator();

@ -38,7 +38,6 @@ public AboutWindow()
mainPanel.setLayout(null);
versionLabel.setFont(Constants.FONT.deriveFont(12));
versionLabel.setForeground(new Color(
GuiActivator.getResources()
.getColor("service.gui.SPLASH_SCREEN_TITLE_COLOR")));

@ -26,6 +26,7 @@
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.Container;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.resources.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
@ -42,6 +43,7 @@
* components.
*
* @author Yana Stamcheva
* @author Lubomir Marinov
*/
public class ExtendedQuickMenu
extends JPanel
@ -50,49 +52,31 @@ public class ExtendedQuickMenu
ComponentListener,
ListSelectionListener
{
private Logger logger = Logger.getLogger(ExtendedQuickMenu.class.getName());
private final Logger logger = Logger.getLogger(ExtendedQuickMenu.class);
private SIPCommToolBar toolBar = new SIPCommToolBar();
private final SIPCommToolBar toolBar = new SIPCommToolBar();
BufferedImage backgroundImage
private final BufferedImage backgroundImage
= ImageLoader.getImage(ImageLoader.TOOL_BAR_BACKGROUND);
Rectangle rectangle
= new Rectangle(0, 0,
backgroundImage.getWidth(null),
backgroundImage.getHeight(null));
private final TexturePaint texture
= new TexturePaint(
backgroundImage,
new Rectangle(
0,
0,
backgroundImage.getWidth(null),
backgroundImage.getHeight(null)));
TexturePaint texture = new TexturePaint(backgroundImage, rectangle);
private static final Dimension PREFERRED_BUTTON_SIZE = new Dimension(
GuiActivator.getResources().getSettingsInt(
"impl.gui.MAIN_TOOLBAR_BUTTON_WIDTH"),
GuiActivator.getResources().getSettingsInt(
"impl.gui.MAIN_TOOLBAR_BUTTON_HEIGHT"));
private ToolBarButton infoButton = new ToolBarButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_INFO_ICON));
private final MoreButton moreButton = new MoreButton();
private ToolBarButton configureButton = new ToolBarButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_CONFIGURE_ICON));
private ToolBarButton hideShowButton = new ToolBarButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_SHOW_OFFLINE_ICON));
private ToolBarButton addButton = new ToolBarButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_ADD_ICON));
private ToolBarButton soundButton = new ToolBarButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_SOUND_ON_ICON));
private ToolBarButton createGroupButton = new ToolBarButton(
ImageLoader.getImage(ImageLoader.QUICK_MENU_CREATE_GROUP_ICON));
private static int DEFAULT_BUTTON_HEIGHT
= GuiActivator.getResources()
.getSettingsInt("impl.gui.MAIN_TOOLBAR_BUTTON_HEIGHT");
private static int DEFAULT_BUTTON_WIDTH
= GuiActivator.getResources()
.getSettingsInt("impl.gui.MAIN_TOOLBAR_BUTTON_WIDTH");
private MoreButton moreButton = new MoreButton();
private MainFrame mainFrame;
private final MainFrame mainFrame;
private final Map<PluginComponent, Component> pluginsTable =
new Hashtable<PluginComponent, Component>();
@ -110,97 +94,76 @@ public ExtendedQuickMenu(MainFrame mainFrame)
this.mainFrame = mainFrame;
this.toolBar.setFloatable(true);
this.toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
this.toolBar.setOpaque(false);
this.toolBar.setRollover(true);
this.toolBar.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 0));
this.toolBar.setFloatable(true);
this.add(toolBar, BorderLayout.CENTER);
this.setMinimumSize(new Dimension(650, DEFAULT_BUTTON_HEIGHT + 5));
this.setPreferredSize(new Dimension(650, DEFAULT_BUTTON_HEIGHT + 5));
this.infoButton.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
this.configureButton.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
this.hideShowButton.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
this.addButton.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
this.soundButton.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
this.createGroupButton.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
this.infoButton.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.CONTACT_INFO"));
this.configureButton.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.SETTINGS"));
this.hideShowButton.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.HIDE_OFFLINE_CONTACTS"));
this.addButton.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.ADD_CONTACT"));
this.soundButton.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.SOUND_ON_OFF"));
this.createGroupButton.setToolTipText(GuiActivator.getResources()
.getI18NString("service.gui.CREATE_GROUP"));
this.updateMuteButton(
GuiActivator.getAudioNotifier().isMute());
this.init();
Dimension size = new Dimension(650, PREFERRED_BUTTON_SIZE.height + 5);
this.setMinimumSize(size);
this.setPreferredSize(size);
addButton(
ImageLoader.QUICK_MENU_ADD_ICON,
"service.gui.ADD_CONTACT",
"add");
addButton(
ImageLoader.QUICK_MENU_CREATE_GROUP_ICON,
"service.gui.CREATE_GROUP",
"createGroup");
addButton(
ImageLoader.QUICK_MENU_CONFIGURE_ICON,
"service.gui.SETTINGS",
"config");
addButton(
ImageLoader.QUICK_MENU_SHOW_OFFLINE_ICON,
"service.gui.HIDE_OFFLINE_CONTACTS",
"search");
ToolBarButton muteButton = addButton(
ImageLoader.QUICK_MENU_SOUND_ON_ICON,
"service.gui.SOUND_ON_OFF",
"sound");
updateMuteButton(
muteButton, GuiActivator.getAudioNotifier().isMute());
this.initPluginComponents();
}
/**
* Initialize the <tt>QuickMenu</tt> by adding the buttons.
*/
private void init()
private ToolBarButton addButton(
ImageID iconImage,
String toolTipKey,
String name)
{
this.add(toolBar, BorderLayout.CENTER);
ToolBarButton button
= new ToolBarButton(ImageLoader.getImage(iconImage));
button.setName(name);
button.setPreferredSize(PREFERRED_BUTTON_SIZE);
button.setToolTipText(
GuiActivator.getResources().getI18NString(toolTipKey));
this.toolBar.add(addButton);
this.toolBar.add(createGroupButton);
this.toolBar.add(configureButton);
this.toolBar.add(hideShowButton);
this.toolBar.add(soundButton);
this.components.add(addButton);
this.components.add(createGroupButton);
this.components.add(configureButton);
this.components.add(hideShowButton);
this.components.add(soundButton);
this.addButton.setName("add");
this.configureButton.setName("config");
this.hideShowButton.setName("search");
this.soundButton.setName("sound");
this.createGroupButton.setName("createGroup");
this.addButton.addMouseListener(this);
this.configureButton.addMouseListener(this);
this.hideShowButton.addMouseListener(this);
this.soundButton.addMouseListener(this);
this.createGroupButton.addMouseListener(this);
this.addButton.addComponentListener(this);
this.configureButton.addComponentListener(this);
this.hideShowButton.addComponentListener(this);
this.infoButton.addComponentListener(this);
this.soundButton.addComponentListener(this);
this.createGroupButton.addComponentListener(this);
toolBar.add(button);
components.add(button);
button.addMouseListener(this);
button.addComponentListener(this);
return button;
}
private void initPluginComponents()
{
// Search for plugin components registered through the OSGI bundle
// context.
ServiceReference[] serRefs = null;
ServiceReference[] serRefs;
String osgiFilter = "("
+ Container.CONTAINER_ID
+ "="+Container.CONTAINER_MAIN_TOOL_BAR.getID()+")";
String osgiFilter
= "("
+ Container.CONTAINER_ID
+ "="
+ Container.CONTAINER_MAIN_TOOL_BAR.getID()
+ ")";
try
{
@ -210,53 +173,35 @@ private void initPluginComponents()
}
catch (InvalidSyntaxException exc)
{
serRefs = null;
logger.error("Could not obtain plugin reference.", exc);
}
if (serRefs != null)
if ((serRefs != null) && (serRefs.length > 0))
{
for (ServiceReference serRef : serRefs)
{
PluginComponent component = (PluginComponent) GuiActivator
.bundleContext.getService(serRef);
boolean added = false;
Object selectedValue = mainFrame.getContactListPanel()
.getContactList().getSelectedValue();
if(component.getComponent() == null)
continue;
try
{
Object selectedValue
= mainFrame.getContactListPanel().getContactList()
.getSelectedValue();
if(selectedValue instanceof MetaContact)
{
component.setCurrentContact((MetaContact)selectedValue);
}
else if(selectedValue instanceof MetaContactGroup)
for (ServiceReference serRef : serRefs)
{
component
.setCurrentContactGroup((MetaContactGroup)selectedValue);
}
Component c = (Component) component.getComponent();
PluginComponent component = (PluginComponent)
GuiActivator.bundleContext.getService(serRef);
if (c != null)
{
if (component.getPositionIndex() > -1)
{
int index = component.getPositionIndex();
this.toolBar.add(c, index);
this.components.add(index, c);
}
else
{
this.toolBar.add(c);
this.components.add(c);
}
this.pluginsTable.put(component, c);
this.repaint();
added
= addPluginComponent(component, selectedValue)
|| added;
}
}
finally
{
if (added)
this.repaint();
}
}
GuiActivator.getUIService().addPluginComponentListener(this);
@ -288,54 +233,59 @@ public void mousePressed(MouseEvent e)
*/
public void pluginComponentAdded(PluginComponentEvent event)
{
PluginComponent pluginComponent = event.getPluginComponent();
PluginComponent component = event.getPluginComponent();
// If the container id doesn't correspond to the id of the plugin
// container we're not interested.
if(!pluginComponent.getContainer()
.equals(Container.CONTAINER_MAIN_TOOL_BAR))
if(!component.getContainer().equals(Container.CONTAINER_MAIN_TOOL_BAR))
return;
int position = pluginComponent.getPositionIndex();
boolean added = addPluginComponent(
component,
mainFrame.getContactListPanel().getContactList().getSelectedValue());
if (added)
{
this.revalidate();
this.repaint();
}
}
Component c = (Component) pluginComponent.getComponent();
private boolean addPluginComponent(
PluginComponent component, Object selectedValue)
{
Component c = (Component) component.getComponent();
if (c == null)
return;
return false;
int position = component.getPositionIndex();
if (position > -1)
{
this.toolBar.add(c, position);
toolBar.add(c, position);
components.add(position, c);
}
else
{
this.toolBar.add(c);
toolBar.add(c);
components.add(c);
}
pluginsTable.put(pluginComponent, c);
pluginsTable.put(component, c);
c.setPreferredSize(
new Dimension(DEFAULT_BUTTON_WIDTH, DEFAULT_BUTTON_HEIGHT));
c.setPreferredSize(PREFERRED_BUTTON_SIZE);
c.addComponentListener(this);
Object selectedValue = mainFrame.getContactListPanel()
.getContactList().getSelectedValue();
if(selectedValue instanceof MetaContact)
{
pluginComponent
.setCurrentContact((MetaContact)selectedValue);
component.setCurrentContact((MetaContact)selectedValue);
}
else if(selectedValue instanceof MetaContactGroup)
{
pluginComponent
component
.setCurrentContactGroup((MetaContactGroup)selectedValue);
}
this.revalidate();
this.repaint();
return true;
}
/**
@ -406,7 +356,7 @@ public void componentShown(ComponentEvent e)
public void valueChanged(ListSelectionEvent e)
{
if((e.getFirstIndex() != -1 || e.getLastIndex() != -1))
if((e.getFirstIndex() != -1) || (e.getLastIndex() != -1))
{
for (PluginComponent plugin : pluginsTable.keySet())
{
@ -426,16 +376,12 @@ else if(selectedValue instanceof MetaContactGroup)
}
}
public void updateMuteButton(boolean isMute)
private void updateMuteButton(ToolBarButton button, boolean isMute)
{
if(!isMute)
this.soundButton.setIcon(
new ImageIcon(ImageLoader.getImage(
ImageLoader.QUICK_MENU_SOUND_ON_ICON)));
else
this.soundButton.setIcon(
new ImageIcon(ImageLoader.getImage(
ImageLoader.QUICK_MENU_SOUND_OFF_ICON)));
button.setIcon(new ImageIcon(ImageLoader.getImage(
isMute
? ImageLoader.QUICK_MENU_SOUND_OFF_ICON
: ImageLoader.QUICK_MENU_SOUND_ON_ICON)));
}
private static class ToolBarButton
@ -449,11 +395,12 @@ public ToolBarButton(Image iconImage)
{
super(new ImageIcon(iconImage));
this.setFont(getFont().deriveFont(Font.BOLD, 10f));
Font font = getFont();
this.setFont(font.deriveFont(Font.BOLD, font.getSize() - 2));
this.setForeground(new Color(
GuiActivator.getResources()
.getColor("service.gui.TOOL_BAR_FOREGROUND")));
this.setVerticalTextPosition(SwingConstants.BOTTOM);
this.setHorizontalTextPosition(SwingConstants.CENTER);
}
@ -491,11 +438,9 @@ private void internalPaintComponent(Graphics g)
Graphics2D g2 = (Graphics2D) g;
Color color = null;
if(isMouseOver)
{
color = new Color(
Color color = new Color(
GuiActivator.getResources()
.getColor("service.gui.TOOL_BAR_ROLLOVER_BACKGROUND"));
@ -506,7 +451,7 @@ private void internalPaintComponent(Graphics g)
if (isMousePressed)
{
color = new Color(
Color color = new Color(
GuiActivator.getResources()
.getColor("service.gui.TOOL_BAR_BACKGROUND"));
@ -587,17 +532,17 @@ else if (buttonName.equals("info"))
.getContactList().getSelectedValue();
if (selectedValue == null
|| !(selectedValue instanceof MetaContact))
|| !(selectedValue instanceof MetaContact))
{
AboutWindow aboutWindow = new AboutWindow();
aboutWindow.pack();
Dimension screenSize
= Toolkit.getDefaultToolkit().getScreenSize();
aboutWindow.setLocation(
Toolkit.getDefaultToolkit().getScreenSize().width / 2
- aboutWindow.getWidth() / 2,
Toolkit.getDefaultToolkit().getScreenSize().height / 2
- aboutWindow.getHeight() / 2);
screenSize.width / 2 - aboutWindow.getWidth() / 2,
screenSize.height / 2 - aboutWindow.getHeight() / 2);
aboutWindow.setVisible(true);
}
@ -643,16 +588,11 @@ else if (buttonName.equals("info"))
}
else if (buttonName.equals("sound"))
{
if(GuiActivator.getAudioNotifier().isMute())
{
updateMuteButton(false);
GuiActivator.getAudioNotifier().setMute(false);
}
else
{
updateMuteButton(true);
GuiActivator.getAudioNotifier().setMute(true);
}
ToolBarButton muteButton = (ToolBarButton) button;
boolean mute = !GuiActivator.getAudioNotifier().isMute();
updateMuteButton(muteButton, mute);
GuiActivator.getAudioNotifier().setMute(mute);
}
else if (buttonName.equals("createGroup"))
{
@ -687,16 +627,16 @@ public void paintComponent(Graphics g)
if (backgroundImage != null)
{
Graphics2D g2 = (Graphics2D) g;
int width = getWidth();
int height = getHeight();
g2.setPaint(texture);
g2.fillRect(0, 2, this.getWidth(), this.getHeight() - 2);
g2.fillRect(0, 2, width, height - 2);
g2.setColor(new Color(
GuiActivator.getResources()
.getColor("service.gui.DESKTOP_BACKGROUND")));
g2.drawRect(0, this.getHeight() - 2, this.getWidth(), 2);
.getColor("service.gui.DESKTOP_BACKGROUND")));
g2.drawRect(0, height - 2, width, 2);
}
}
}

@ -123,7 +123,7 @@ public GlobalStatusSelectorBox(MainFrame mainFrame)
titleLabel = new JLabel("Set global status");
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
titleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
this.add(titleLabel);
this.addSeparator();

@ -83,7 +83,7 @@ public PresenceStatusMenu( MainFrame mainFrame,
titleLabel = new JLabel(protocolProvider.getAccountID().getDisplayName());
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
titleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
this.add(titleLabel);
this.addSeparator();

@ -63,7 +63,7 @@ private SimpleStatusMenu( ProtocolProviderService protocolProvider,
JLabel titleLabel = new JLabel(displayName);
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
titleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD));
titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
this.add(titleLabel);
this.addSeparator();

@ -11,6 +11,7 @@
import java.awt.image.*;
import java.io.*;
import javax.swing.*;
import javax.swing.text.html.*;
import net.java.sip.communicator.impl.gui.*;
@ -22,10 +23,9 @@
*
* @author Yana Stamcheva
*/
public class Constants
{
private static Logger logger = Logger.getLogger(Constants.class);
private static final Logger logger = Logger.getLogger(Constants.class);
/**
* Indicates that the user is connected and ready to communicate.
@ -209,20 +209,41 @@ public class Constants
*/
/**
* The name of the font used in this ui implementation.
* The default <tt>Font</tt> object used through this ui implementation.
*/
public static final String FONT_NAME = "Verdana";
public static final Font FONT;
/**
* The size of the font used in this ui implementation.
*/
public static final String FONT_SIZE = "12";
static
{
Font font = null;
String fontName = null;
int fontSize = 0;
LookAndFeel laf = UIManager.getLookAndFeel();
if ((laf != null)
&& "com.sun.java.swing.plaf.windows.WindowsLookAndFeel".equals(
laf.getClass().getName()))
{
Object desktopPropertyValue
= Toolkit.getDefaultToolkit().getDesktopProperty(
"win.messagebox.font");
/**
* The default <tt>Font</tt> object used through this ui implementation.
*/
public static final Font FONT = new Font(Constants.FONT_NAME, Font.PLAIN,
Integer.parseInt(Constants.FONT_SIZE));
if (desktopPropertyValue instanceof Font)
{
font = (Font) desktopPropertyValue;
fontName = font.getFontName();
fontSize = font.getSize();
}
}
FONT
= (font == null)
? new Font(
(fontName == null) ? "Verdana" : fontName,
Font.PLAIN,
(fontSize == 0) ? 12 : fontSize)
: font;
}
/*
* ======================================================================
@ -394,17 +415,41 @@ public static void loadAdiumStyle(){
* Temporary method to load the css style used in the chat window.
* @param style
*/
public static void loadSimpleStyle(StyleSheet style) {
InputStream is = GuiActivator.getResources()
.getSettingsInputStream("service.gui.HTML_TEXT_STYLE");
Reader r = new BufferedReader(new InputStreamReader(is));
try {
public static void loadSimpleStyle(StyleSheet style, Font defaultFont)
{
Reader r =
new BufferedReader(
new InputStreamReader(
GuiActivator.getResources().getSettingsInputStream(
"service.gui.HTML_TEXT_STYLE")));
if (defaultFont != null)
style.addRule(
"body, div, h1, h2, h3, h4, h5, h6, h7, p, td, th { "
+ "font-family: \""
+ defaultFont.getName()
+ "\"; font-size: "
+ defaultFont.getSize()
+ "pt; }");
try
{
style.loadRules(r, null);
r.close();
} catch (IOException e) {
logger.error("Failed to load css style.", e);
}
catch (IOException ex)
{
logger.error("Failed to load CSS stream.", ex);
}
finally
{
try
{
r.close();
}
catch (IOException ex)
{
logger.error("Failed to close CSS stream.", ex);
}
}
}
}

@ -1356,16 +1356,13 @@ public static Image getAccountStatusImage(ProtocolProviderService pps)
{
BufferedImage buffImage =
new BufferedImage(22, 16, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) buffImage.getGraphics();
AlphaComposite ac =
AlphaComposite.getInstance(AlphaComposite.SRC_OVER);
AntialiasingManager.activateAntialiasing(g);
g.setColor(Color.DARK_GRAY);
g.setFont(Constants.FONT.deriveFont(Font.BOLD, 9));
g.drawImage(statusImage, 0, 0, null);
g.setComposite(ac);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
g.drawString(Integer.toString(index + 1), 14, 8);
img = buffImage;

@ -438,7 +438,8 @@ static interface EntityMap {
}
static class PrimitiveEntityMap implements EntityMap {
private Map mapNameToValue = new HashMap();
private final Map<String, Integer> mapNameToValue
= new HashMap<String, Integer>();
private IntHashMap mapValueToName = new IntHashMap();
@ -446,7 +447,7 @@ static class PrimitiveEntityMap implements EntityMap {
* {@inheritDoc}
*/
public void add(String name, int value) {
mapNameToValue.put(name, new Integer(value));
mapNameToValue.put(name, value);
mapValueToName.put(value, name);
}
@ -461,43 +462,37 @@ public String name(int value) {
* {@inheritDoc}
*/
public int value(String name) {
Object value = mapNameToValue.get(name);
if (value == null) {
return -1;
}
return ((Integer) value).intValue();
Integer value = mapNameToValue.get(name);
return (value == null) ? -1 : value;
}
}
static abstract class MapIntMap implements Entities.EntityMap {
protected Map mapNameToValue;
protected Map<String, Integer> mapNameToValue;
protected Map mapValueToName;
protected Map<Integer, String> mapValueToName;
/**
* {@inheritDoc}
*/
public void add(String name, int value) {
mapNameToValue.put(name, new Integer(value));
mapValueToName.put(new Integer(value), name);
mapNameToValue.put(name, value);
mapValueToName.put(value, name);
}
/**
* {@inheritDoc}
*/
public String name(int value) {
return (String) mapValueToName.get(new Integer(value));
return mapValueToName.get(value);
}
/**
* {@inheritDoc}
*/
public int value(String name) {
Object value = mapNameToValue.get(name);
if (value == null) {
return -1;
}
return ((Integer) value).intValue();
Integer value = mapNameToValue.get(name);
return (value == null) ? -1 : value;
}
}
@ -506,8 +501,8 @@ static class HashEntityMap extends MapIntMap {
* Constructs a new instance of <code>HashEntityMap</code>.
*/
public HashEntityMap() {
mapNameToValue = new HashMap();
mapValueToName = new HashMap();
mapNameToValue = new HashMap<String, Integer>();
mapValueToName = new HashMap<Integer, String>();
}
}
@ -516,8 +511,8 @@ static class TreeEntityMap extends MapIntMap {
* Constructs a new instance of <code>TreeEntityMap</code>.
*/
public TreeEntityMap() {
mapNameToValue = new TreeMap();
mapValueToName = new TreeMap();
mapNameToValue = new TreeMap<String, Integer>();
mapValueToName = new TreeMap<Integer, String>();
}
}
@ -1033,8 +1028,8 @@ static class IntHashMap {
* table.</p>
*/
private static class Entry {
int hash;
int key;
final int hash;
final int key;
Object value;
Entry next;

Loading…
Cancel
Save