diff options
4 files changed, 471 insertions, 136 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 1da0323..a66bf39 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -2440,7 +2440,6 @@ public class ChatPanel this.getChatWritePanel().getEditorPane().repaint(); } - /** * Shows the font chooser dialog */ @@ -2449,33 +2448,34 @@ public class ChatPanel JEditorPane editorPane = writeMessagePanel.getEditorPane(); FontChooser fontChooser = new FontChooser(); - fontChooser.setFontFamily( - editorPane.getFont().getFontName()); - fontChooser.setFontSize( - editorPane.getFont().getSize()); - - fontChooser.setBoldStyle(editorPane.getFont().isBold()); - fontChooser.setItalicStyle(editorPane.getFont().isItalic()); - int result = fontChooser.showDialog(this); - if (result == FontChooser.OK_OPTION) + if (result != FontChooser.CANCEL_OPTION) { + String fontFamily = fontChooser.getFontFamily(); + int fontSize = fontChooser.getFontSize(); + boolean isBold = fontChooser.isBoldStyleSelected(); + boolean isItalic = fontChooser.isItalicStyleSelected(); + boolean isUnderline = fontChooser.isUnderlineStyleSelected(); + Color fontColor = fontChooser.getFontColor(); + // Font family and size - writeMessagePanel.setFontFamilyAndSize( - fontChooser.getFontFamily(), - fontChooser.getFontSize()); + writeMessagePanel.setFontFamilyAndSize(fontFamily, fontSize); // Font style - writeMessagePanel.setBoldStyleEnable( - fontChooser.isBoldStyleSelected()); - writeMessagePanel.setItalicStyleEnable( - fontChooser.isItalicStyleSelected()); - writeMessagePanel.setUnderlineStyleEnable( - fontChooser.isUnderlineStyleSelected()); + writeMessagePanel.setBoldStyleEnable(isBold); + writeMessagePanel.setItalicStyleEnable(isItalic); + writeMessagePanel.setUnderlineStyleEnable(isUnderline); // Font color - writeMessagePanel.setFontColor(fontChooser.getFontColor()); + writeMessagePanel.setFontColor(fontColor); + + writeMessagePanel.saveDefaultFontConfiguration( fontFamily, + fontSize, + isBold, + isItalic, + isUnderline, + fontColor); } editorPane.requestFocus(); diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index 3ea9afb..29476f8 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -111,8 +111,8 @@ public class ChatWritePanel this.add(centerPanel, BorderLayout.CENTER); - this.rightButtonMenu = - new WritePanelRightButtonMenu(chatPanel.getChatContainer()); + this.rightButtonMenu + = new WritePanelRightButtonMenu(chatPanel.getChatContainer()); this.typingTimer.setRepeats(true); @@ -131,6 +131,32 @@ public class ChatWritePanel this.changeSendCommand((messageCommand == null || messageCommand .equalsIgnoreCase("enter"))); + + initDefaultFontConfiguration(); + } + + /** + * Initializes the default font configuration for this chat write area. + */ + private void initDefaultFontConfiguration() + { + String fontFamily = ConfigurationManager.getChatDefaultFontFamily(); + int fontSize = ConfigurationManager.getChatDefaultFontSize(); + + // Font family and size + if (fontFamily != null && fontSize > 0) + setFontFamilyAndSize(fontFamily, fontSize); + + // Font style + setBoldStyleEnable(ConfigurationManager.isChatFontBold()); + setItalicStyleEnable(ConfigurationManager.isChatFontItalic()); + setUnderlineStyleEnable(ConfigurationManager.isChatFontUnderline()); + + // Font color + Color fontColor = ConfigurationManager.getChatDefaultFontColor(); + + if (fontColor != null) + setFontColor(fontColor); } /** @@ -1008,6 +1034,31 @@ public class ChatWritePanel } /** + * Saves the given font configuration as default, thus making it the default + * configuration for all chats. + * + * @param fontFamily the font family + * @param fontSize the font size + * @param isBold indicates if the font is bold + * @param isItalic indicates if the font is italic + * @param isUnderline indicates if the font is underline + */ + public void saveDefaultFontConfiguration( String fontFamily, + int fontSize, + boolean isBold, + boolean isItalic, + boolean isUnderline, + Color color) + { + ConfigurationManager.setChatDefaultFontFamily(fontFamily); + ConfigurationManager.setChatDefaultFontSize(fontSize); + ConfigurationManager.setChatFontIsBold(isBold); + ConfigurationManager.setChatFontIsItalic(isItalic); + ConfigurationManager.setChatFontIsUnderline(isUnderline); + ConfigurationManager.setChatDefaultFontColor(color); + } + + /** * Sets the font family and size * @param family the family name * @param size the size @@ -1019,13 +1070,15 @@ public class ChatWritePanel = new ActionEvent( editorPane, ActionEvent.ACTION_PERFORMED, family); + Action action = new StyledEditorKit.FontFamilyAction(family, family); action.actionPerformed(evt); // Size evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, Integer.toString(size)); - action = new StyledEditorKit.FontSizeAction(Integer.toString(size), size); + action = new StyledEditorKit.FontSizeAction( + Integer.toString(size), size); action.actionPerformed(evt); } @@ -1035,7 +1088,10 @@ public class ChatWritePanel */ public void setBoldStyleEnable(boolean b) { - if (b) + StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit(); + MutableAttributeSet attr = editorKit.getInputAttributes(); + + if (b && !StyleConstants.isBold(attr)) { setStyleConstant( new HTMLEditorKit.BoldAction(), StyleConstants.Bold); @@ -1048,7 +1104,10 @@ public class ChatWritePanel */ public void setItalicStyleEnable(boolean b) { - if (b) + StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit(); + MutableAttributeSet attr = editorKit.getInputAttributes(); + + if (b && !StyleConstants.isItalic(attr)) { setStyleConstant( new HTMLEditorKit.ItalicAction(), StyleConstants.Italic); @@ -1061,7 +1120,10 @@ public class ChatWritePanel */ public void setUnderlineStyleEnable(boolean b) { - if (b) + StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit(); + MutableAttributeSet attr = editorKit.getInputAttributes(); + + if (b && !StyleConstants.isUnderline(attr)) { setStyleConstant( new HTMLEditorKit.UnderlineAction(), StyleConstants.Underline); @@ -1076,6 +1138,7 @@ public class ChatWritePanel { ActionEvent evt = new ActionEvent(editorPane, ActionEvent.ACTION_PERFORMED, ""); + Action action = new HTMLEditorKit.ForegroundAction( Integer.toString(color.getRGB()), @@ -1084,11 +1147,17 @@ public class ChatWritePanel action.actionPerformed(evt); } + /** + * Sets the given style constant. + * + * @param action the action + * @param styleConstant the style constant + */ private void setStyleConstant(Action action, Object styleConstant) { ActionEvent event = new ActionEvent(editorPane, - ActionEvent.ACTION_PERFORMED, - styleConstant.toString()); + ActionEvent.ACTION_PERFORMED, + styleConstant.toString()); action.actionPerformed(event); } @@ -1173,5 +1242,8 @@ public class ChatWritePanel smsCharCountLabel.setText(String.valueOf(smsCharCount)); smsNumberLabel.setText(String.valueOf(smsNumberCount)); } + + if (getText() == null || getText().isEmpty()) + initDefaultFontConfiguration(); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java b/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java index 0732eb8..a4b1a91 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/FontChooser.java @@ -13,6 +13,7 @@ import javax.swing.*; import javax.swing.event.*; import net.java.sip.communicator.impl.gui.*; +import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.resources.*; import net.java.sip.communicator.util.swing.*; @@ -26,131 +27,178 @@ public class FontChooser implements ActionListener, ListSelectionListener { private InputList fontFamilyPanel; - + private InputList fontSizePanel; - + private JCheckBox boldCheckBox; - + private JCheckBox italicCheckBox; - + private JCheckBox underlineCheckBox; - + private ColorLabel colorLabel; - + private JLabel previewLabel; - + private String[] fontFamilies; - - private final String[] fontSizes = { "8", "9", "10", "11", "12", "14", "16", + + private final String[] fontSizes + = { "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", "72" }; - + private static final String previewText = "Preview Text"; - + private static final String ACTCMD_CHOOSE_COLOR = "ACTCMD_CHOOSE_COLOR"; - + public static final int OK_OPTION = 1; public static final int CANCEL_OPTION = 0; + protected int option = CANCEL_OPTION; - + public FontChooser() { ResourceManagementService res = GuiActivator.getResources(); + this.setLayout(new BorderLayout(5, 5)); - + this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + //-- Init InputList panels // Font family - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsEnvironment ge + = GraphicsEnvironment.getLocalGraphicsEnvironment(); this.fontFamilies = ge.getAvailableFontFamilyNames(); - this.fontFamilyPanel = new InputList(res.getI18NString("service.gui.FONT_FAMILY"), - this.fontFamilies); + this.fontFamilyPanel + = new InputList(res.getI18NString("service.gui.FONT_FAMILY"), + this.fontFamilies); this.fontFamilyPanel.addListSelectionListener(this); - + // Font size - this.fontSizePanel = new InputList(res.getI18NString("service.gui.FONT_SIZE"), - this.fontSizes); + this.fontSizePanel + = new InputList(res.getI18NString("service.gui.FONT_SIZE"), + this.fontSizes); + this.fontSizePanel.addListSelectionListener(this); - + JPanel listsPanels = new JPanel(new GridLayout(1, 2, 5, 5)); listsPanels.add(this.fontFamilyPanel, BorderLayout.WEST); listsPanels.add(this.fontSizePanel, BorderLayout.EAST); - + //-- Style - JLabel styleLabel = new JLabel(res.getI18NString("service.gui.FONT_STYLE")); + JLabel styleLabel + = new JLabel(res.getI18NString("service.gui.FONT_STYLE")); styleLabel.setPreferredSize(new Dimension(100, 0)); styleLabel.setFont(styleLabel.getFont().deriveFont(Font.BOLD)); - + // Bold - this.boldCheckBox = new JCheckBox(res.getI18NString("service.gui.FONT_BOLD")); + this.boldCheckBox + = new JCheckBox(res.getI18NString("service.gui.FONT_BOLD")); this.boldCheckBox.addActionListener(this); this.boldCheckBox.setOpaque(false); // Italic - this.italicCheckBox = new JCheckBox(res.getI18NString("service.gui.FONT_ITALIC")); + this.italicCheckBox + = new JCheckBox(res.getI18NString("service.gui.FONT_ITALIC")); this.italicCheckBox.addActionListener(this); // Underline - this.underlineCheckBox = new JCheckBox(res.getI18NString("service.gui.FONT_UNDERLINE")); + this.underlineCheckBox + = new JCheckBox(res.getI18NString("service.gui.FONT_UNDERLINE")); this.underlineCheckBox.addActionListener(this); - + // Panel JPanel styleGridPanel = new JPanel(new GridLayout(1, 3, 5, 5)); styleGridPanel.add(this.boldCheckBox); styleGridPanel.add(this.italicCheckBox); styleGridPanel.add(this.underlineCheckBox); - + JPanel stylePanel = new JPanel(new BorderLayout(10, 10)); stylePanel.add(styleLabel, BorderLayout.WEST); stylePanel.add(styleGridPanel, BorderLayout.CENTER); - + //-- Color - JLabel colorTextLabel = new JLabel(res.getI18NString("service.gui.FONT_COLOR")); + JLabel colorTextLabel + = new JLabel(res.getI18NString("service.gui.FONT_COLOR")); colorTextLabel.setPreferredSize(new Dimension(100, 0)); colorTextLabel.setFont(styleLabel.getFont().deriveFont(Font.BOLD)); - + // Color label this.colorLabel = new ColorLabel(); this.colorLabel.setOpaque(true); this.colorLabel.setBackground(Color.BLACK); this.colorLabel.setPreferredSize(new Dimension(18, 18)); - + // Color button - JButton colorButton = new JButton(res.getI18NString("service.gui.SELECT_COLOR")); + JButton colorButton + = new JButton(res.getI18NString("service.gui.SELECT_COLOR")); colorButton.addActionListener(this); colorButton.setName(ACTCMD_CHOOSE_COLOR); - + // Panel JPanel colorPanelCenter = new JPanel(new FlowLayout(FlowLayout.LEFT)); colorPanelCenter.add(colorLabel); colorPanelCenter.add(colorButton); - + JPanel colorPanel = new JPanel(new BorderLayout()); colorPanel.add(colorTextLabel, BorderLayout.WEST); colorPanel.add(colorPanelCenter, BorderLayout.CENTER); - - + // Format Panel JPanel formatPanel = new JPanel(); formatPanel.setLayout(new BoxLayout(formatPanel, BoxLayout.Y_AXIS)); formatPanel.add(listsPanels); formatPanel.add(stylePanel); formatPanel.add(colorPanel); - + this.add(formatPanel, BorderLayout.NORTH); - + // Preview Label this.previewLabel = new JLabel(previewText, JLabel.CENTER); this.previewLabel.setOpaque(true); this.previewLabel.setBackground(Color.WHITE); this.previewLabel.setPreferredSize(new Dimension(0, 100)); - this.previewLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); - + this.previewLabel.setBorder( + BorderFactory.createLineBorder(Color.BLACK, 1)); + this.add(this.previewLabel, BorderLayout.CENTER); + + initDefaults(); } - + + /** + * Initializes previously saved default fonts. + */ + private void initDefaults() + { + String defaultFontFamily + = ConfigurationManager.getChatDefaultFontFamily(); + + int defaultFontSize + = ConfigurationManager.getChatDefaultFontSize(); + + Color defaultFontColor + = ConfigurationManager.getChatDefaultFontColor(); + + if (defaultFontFamily != null) + setFontFamily(defaultFontFamily); + + if (defaultFontSize > 0) + setFontSize(defaultFontSize); + + setBoldStyle(ConfigurationManager.isChatFontBold()); + setItalicStyle(ConfigurationManager.isChatFontItalic()); + setUnderlineStyle(ConfigurationManager.isChatFontUnderline()); + + if (defaultFontColor != null) + setColor(defaultFontColor); + } + + /** + * Updates the font preview area. + */ private void updatePreview() { Font f = new Font(this.fontFamilyPanel.getSelected(), Font.PLAIN, this.fontSizePanel.getSelectedInt()); - + String text = this.fontFamilyPanel.getSelected(); if (this.boldCheckBox.isSelected()) @@ -159,7 +207,7 @@ public class FontChooser text = "<i>" + text + "</i>"; if (this.underlineCheckBox.isSelected()) text = "<u>" + text + "</u>"; - + this.previewLabel.setFont(f); this.previewLabel.setForeground(this.colorLabel.getBackground()); this.previewLabel.setText("<html>"+text+"</html>"); @@ -179,31 +227,33 @@ public class FontChooser this.colorLabel.setBackground(c); } } - updatePreview(); } - + public void valueChanged(ListSelectionEvent e) { updatePreview(); } - + /** * Sets the family name of the font - * @param family the familly name + * @param family the family name */ public void setFontFamily(String family) { if (family.endsWith(".plain")) family = family.replace(".plain", ""); - - for (String f : this.fontFamilies) - if (family.equals(f)) - this.fontFamilyPanel.setSelected(family); - - this.updatePreview(); + + for (String f : fontFamilies) + { + String oldF = f; + if (family.equals(f) || family.equals(f.replaceAll(" ", ""))) + fontFamilyPanel.setSelected(oldF); + } + + updatePreview(); } - + /** * Sets the size of the font * @param size @@ -213,7 +263,7 @@ public class FontChooser this.fontSizePanel.setSelectedInt(size); this.updatePreview(); } - + /** * Enables the bold style * @param b TRUE enable - FALSE disable @@ -223,7 +273,7 @@ public class FontChooser this.boldCheckBox.setSelected(b); this.updatePreview(); } - + /** * Enables the italic style * @param b TRUE enable - FALSE disable @@ -233,7 +283,7 @@ public class FontChooser this.italicCheckBox.setSelected(b); this.updatePreview(); } - + /** * Enables the underline style * @param b TRUE enable - FALSE disable @@ -243,7 +293,7 @@ public class FontChooser this.underlineCheckBox.setSelected(b); this.updatePreview(); } - + /** * Sets the font's color * @param c the color @@ -253,7 +303,7 @@ public class FontChooser this.colorLabel.setBackground(c); this.updatePreview(); } - + /** * Returns the family name of the selected font * @return the family name of the selected font @@ -264,7 +314,7 @@ public class FontChooser { return this.fontFamilyPanel.getSelected(); } - + /** * Returns the size of the selected font * @return the size of the selected font @@ -275,7 +325,7 @@ public class FontChooser { return this.fontSizePanel.getSelectedInt(); } - + /** * Checks if bold checkbox is selected * @return TRUE is the checkbox is selected - FALSE otherwise @@ -284,7 +334,7 @@ public class FontChooser { return this.boldCheckBox.isSelected(); } - + /** * Checks if italic checkbox is selected * @return TRUE is the checkbox is selected - FALSE otherwise @@ -293,7 +343,7 @@ public class FontChooser { return this.italicCheckBox.isSelected(); } - + /** * Checks if underline checkbox is selected * @return TRUE is the checkbox is selected - FALSE otherwise @@ -302,7 +352,7 @@ public class FontChooser { return this.underlineCheckBox.isSelected(); } - + /** * Returns the font color * @return the font color @@ -311,7 +361,7 @@ public class FontChooser { return this.colorLabel.getBackground(); } - + private static class ColorLabel extends JLabel { public void paintComponent(Graphics g) @@ -331,30 +381,30 @@ public class FontChooser } } } - + private class InputList extends JPanel implements KeyListener, ListSelectionListener - { + { private JLabel label = new JLabel(); - + private JTextField textField = new JTextField(); - + private JList list; - + public InputList(String title, Object[] data) { this.setLayout(new BorderLayout()); - + this.label.setText(title); this.label.setFont(this.label.getFont().deriveFont(Font.BOLD)); this.add(this.label, BorderLayout.NORTH); - + JPanel middlePanel = new JPanel(new BorderLayout()); - + this.textField.addKeyListener(this); middlePanel.add(this.textField, BorderLayout.NORTH); - + this.list = new JList(data); this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); this.list.setVisibleRowCount(5); @@ -362,36 +412,36 @@ public class FontChooser this.list.addListSelectionListener(this); this.setFocusable(false); middlePanel.add(new JScrollPane(this.list), BorderLayout.CENTER); - + this.add(middlePanel, BorderLayout.CENTER); } - + public void setSelected(String value) { ListModel l = this.list.getModel(); boolean inList = false; - + for (int i=0; i<l.getSize() && !inList; i++) if (l.getElementAt(i).toString().equals(value)) inList = true; - + if (inList) this.list.setSelectedValue(value, true); else this.list.clearSelection(); this.textField.setText(value); } - + public String getSelected() { return this.textField.getText(); } - + public void setSelectedInt(int value) { this.setSelected(Integer.toString(value)); } - + public int getSelectedInt() { try @@ -403,7 +453,7 @@ public class FontChooser return -1; } } - + public void addListSelectionListener(ListSelectionListener l) { this.list.addListSelectionListener(l); @@ -413,7 +463,7 @@ public class FontChooser { String selectedValue = (String) this.list.getSelectedValue(); String oldValue = this.textField.getText(); - + this.textField.setText(selectedValue); if (!oldValue.equalsIgnoreCase(selectedValue)) { @@ -424,12 +474,13 @@ public class FontChooser public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT) + if (e.getKeyCode() == KeyEvent.VK_LEFT + || e.getKeyCode() == KeyEvent.VK_RIGHT) return; - + String elem, key = this.textField.getText().toLowerCase(); ListModel model = this.list.getModel(); - + for (int i=0; i<model.getSize(); i++) { elem = model.getElementAt(i).toString(); @@ -454,11 +505,11 @@ public class FontChooser this.list.setSelectedIndex(i+1); } } - + // Not used public void keyTyped(KeyEvent e) {;} } - + // Dialog creation public int showDialog(Component parent) { @@ -468,23 +519,25 @@ public class FontChooser dialog = null; return this.option; } - + + /** + * Creates this dialog. + * + * @param parent the parent dialog + * @return the created dialog + */ private SIPCommDialog createDialog(Component parent) { - final SIPCommDialog d = new SIPCommDialog() - { - @Override - protected void close(boolean isEscaped){;} - }; - + final SIPCommDialog d = new SIPCommDialog(); + ResourceManagementService res = GuiActivator.getResources(); - + d.setTitle(res.getI18NString("service.gui.FONT")); d.setModal(true); - + // Ok and Cancel buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); - + JButton okButton = new JButton(GuiActivator.getResources() .getI18NString("service.gui.OK")); okButton.addActionListener(new ActionListener() { @@ -495,7 +548,7 @@ public class FontChooser } }); buttonsPanel.add(okButton); - + JButton cancelButton = new JButton(GuiActivator.getResources() .getI18NString("service.gui.CANCEL")); cancelButton.addActionListener(new ActionListener() { @@ -506,15 +559,15 @@ public class FontChooser } }); buttonsPanel.add(cancelButton); - + d.getContentPane().setLayout(new BorderLayout()); d.getContentPane().add(this, BorderLayout.CENTER); d.getContentPane().add(buttonsPanel, BorderLayout.SOUTH); - + d.pack(); d.setResizable(false); d.setLocationRelativeTo(parent); - + return d; } } diff --git a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java index 3060000..e8963da 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ConfigurationManager.java @@ -6,8 +6,9 @@ */ package net.java.sip.communicator.impl.gui.utils; +import java.awt.*; import java.beans.*; -import java.util.*; +import java.util.List; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.service.configuration.*; @@ -163,6 +164,36 @@ public class ConfigurationManager private static boolean isAdvancedAccountConfigDisabled; /** + * The default font family used in chat windows. + */ + private static String defaultFontFamily; + + /** + * The default font size used in chat windows. + */ + private static String defaultFontSize; + + /** + * Indicates if the font is bold in chat windows. + */ + private static boolean isDefaultFontBold = false; + + /** + * Indicates if the font is italic in chat windows. + */ + private static boolean isDefaultFontItalic = false; + + /** + * Indicates if the font is underline in chat windows. + */ + private static boolean isDefaultFontUnderline = false; + + /** + * The default font color used in chat windows. + */ + private static int defaultFontColor; + + /** * Loads all user interface configurations. */ public static void loadGuiConfigurations() @@ -286,12 +317,13 @@ public class ConfigurationManager = "service.gui.LEAVE_CHATROOM_ON_WINDOW_CLOSE"; String isLeaveChatRoomOnWindowCloseEnabledString - = configService.getString(isLeaveChatRoomOnWindowCloseEnabledStringProperty); + = configService.getString( + isLeaveChatRoomOnWindowCloseEnabledStringProperty); if(isLeaveChatRoomOnWindowCloseEnabledString == null) isLeaveChatRoomOnWindowCloseEnabledString = - GuiActivator.getResources(). - getSettingsString(isLeaveChatRoomOnWindowCloseEnabledStringProperty); + GuiActivator.getResources().getSettingsString( + isLeaveChatRoomOnWindowCloseEnabledStringProperty); if(isLeaveChatRoomOnWindowCloseEnabledString != null && isLeaveChatRoomOnWindowCloseEnabledString.length() > 0) @@ -476,11 +508,42 @@ public class ConfigurationManager isAdvancedConfigDisabled = Boolean.parseBoolean(advancedConfigDisabledDefaultProp); + // Load the advanced account configuration disabled. isAdvancedAccountConfigDisabled = configService.getBoolean( "net.java.sip.communicator.impl.gui.main.account." + "ADVANCED_CONFIG_DISABLED", isAdvancedConfigDisabled); + + // Load default font family string. + defaultFontFamily = configService.getString( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_FAMILY"); + + // Load default font size. + defaultFontSize = configService.getString( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_SIZE"); + + // Load isBold chat property. + isDefaultFontBold + = configService.getBoolean( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_BOLD", + isDefaultFontBold); + + // Load isItalic chat property. + isDefaultFontItalic + = configService.getBoolean( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_ITALIC", + isDefaultFontItalic); + + // Load isUnderline chat property. + isDefaultFontUnderline + = configService.getBoolean( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_UNDERLINE", + isDefaultFontUnderline); + + // Load default font color property. + defaultFontColor = configService.getInt( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_COLOR", 0); } /** @@ -696,6 +759,69 @@ public class ConfigurationManager } /** + * Returns the default chat font family. + * + * @return the default chat font family + */ + public static String getChatDefaultFontFamily() + { + return defaultFontFamily; + } + + /** + * Returns the default chat font size. + * + * @return the default chat font size + */ + public static int getChatDefaultFontSize() + { + if (defaultFontSize != null && defaultFontSize.length() > 0) + return new Integer(defaultFontSize).intValue(); + + return -1; + } + + /** + * Returns the default chat font color. + * + * @return the default chat font color + */ + public static Color getChatDefaultFontColor() + { + return new Color(defaultFontColor); + } + + /** + * Returns the default chat font bold. + * + * @return the default chat font bold + */ + public static boolean isChatFontBold() + { + return isDefaultFontBold; + } + + /** + * Returns the default chat font italic. + * + * @return the default chat font italic + */ + public static boolean isChatFontItalic() + { + return isDefaultFontItalic; + } + + /** + * Returns the default chat font underline. + * + * @return the default chat font underline + */ + public static boolean isChatFontUnderline() + { + return isDefaultFontUnderline; + } + + /** * Sets the advanced account config disabled property. * * @param disabled the new value to set @@ -1065,6 +1191,90 @@ public class ConfigurationManager } /** + * Sets the default font family. + * + * @param fontFamily the default font family name + */ + public static void setChatDefaultFontFamily(String fontFamily) + { + defaultFontFamily = fontFamily; + + configService.setProperty( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_FAMILY", + fontFamily); + } + + /** + * Sets the default font size. + * + * @param fontSize the default font size + */ + public static void setChatDefaultFontSize(int fontSize) + { + defaultFontSize = String.valueOf(fontSize); + + configService.setProperty( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_SIZE", + fontSize); + } + + /** + * Sets the default isBold property. + * + * @param isBold indicates if the default chat font is bold + */ + public static void setChatFontIsBold(boolean isBold) + { + isDefaultFontBold = isBold; + + configService.setProperty( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_BOLD", + isBold); + } + + /** + * Sets the default isItalic property. + * + * @param isBold indicates if the default chat font is italic + */ + public static void setChatFontIsItalic(boolean isItalic) + { + isDefaultFontItalic = isItalic; + + configService.setProperty( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_ITALIC", + isItalic); + } + + /** + * Sets the default isUnderline property. + * + * @param isBold indicates if the default chat font is underline + */ + public static void setChatFontIsUnderline(boolean isUnderline) + { + isDefaultFontUnderline = isUnderline; + + configService.setProperty( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_UNDERLINE", + isUnderline); + } + + /** + * Sets the default font color. + * + * @param fontFamily the default font color + */ + public static void setChatDefaultFontColor(Color fontColor) + { + defaultFontColor = fontColor.getRGB(); + + configService.setProperty( + "net.java.sip.communicator.impl.gui.chat.DEFAULT_FONT_COLOR", + defaultFontColor); + } + + /** * Saves a chat room through the <tt>ConfigurationService</tt>. * * @param protocolProvider the protocol provider to which the chat room |