source: branches/2.2/jabberit_messenger/java_source/src/nu/fw/jeti/plugins/xhtml/PrefPanel.java @ 3102

Revision 3102, 3.0 KB checked in by amuller, 14 years ago (diff)

Ticket #986 - Efetuado merge para o Branch 2.2( atualizacao do modulo)

  • Property svn:executable set to *
Line 
1package nu.fw.jeti.plugins.xhtml;
2
3import java.awt.Color;
4import java.awt.GridBagConstraints;
5import java.awt.GridBagLayout;
6import java.awt.Insets;
7
8import javax.swing.Box;
9import javax.swing.JLabel;
10import javax.swing.text.AttributeSet;
11import javax.swing.text.MutableAttributeSet;
12import javax.swing.text.SimpleAttributeSet;
13import javax.swing.text.StyleConstants;
14import javax.swing.text.html.StyleSheet;
15
16import nu.fw.jeti.jabber.Backend;
17import nu.fw.jeti.plugins.PreferencesPanel;
18import nu.fw.jeti.plugins.xhtml.fontchooser.FontPanel;
19import nu.fw.jeti.util.I18N;
20import nu.fw.jeti.util.Preferences;
21
22
23/**
24 * <p>Title: J2M</p>
25 * <p>Description: </p>
26 * <p>Copyright: Copyright (c) 2002</p>
27 * <p>Company: </p>
28 * @author E.S. de Boer
29 * @version 1.0
30 */
31
32public class PrefPanel extends PreferencesPanel
33{
34        private FontPanel fontPanel = new FontPanel();
35        private StyleSheet styleSheet = new StyleSheet();
36       
37        public PrefPanel(Backend backend)
38        {
39        setLayout(new GridBagLayout());
40        GridBagConstraints c = new GridBagConstraints();
41        c.anchor = GridBagConstraints.LINE_START;
42        c.insets = new Insets(3, 5, 0, 3);
43        c.gridwidth = GridBagConstraints.REMAINDER;
44
45                //this.backend = backend;
46                MutableAttributeSet set = new SimpleAttributeSet();
47                int i = Preferences.getInteger("xhtml", "foreground", 0);
48                if (i != 0)
49                {
50                        StyleConstants.setForeground(set, new Color(i));
51                }
52                i = Preferences.getInteger("xhtml", "background", 0);
53                if (i != 0)
54                {               
55                                StyleConstants.setBackground(set, new Color(i));
56                }
57                i = Preferences.getInteger("xhtml", "font-size", 0);
58                if (i != 0)
59                {
60                        StyleConstants.setFontSize(set, i);
61                }
62                StyleConstants.setBold(set,Preferences.getBoolean("xhtml","bold",false));
63            StyleConstants.setItalic(set,Preferences.getBoolean("xhtml","italic",false));
64                StyleConstants.setFontFamily(set, Preferences.getString("xhtml", "font-family", "Arial"));
65                fontPanel.setAttributes(set);
66
67                add(new JLabel(I18N.gettext("xhtml.The_font_used_when_sending_messages")), c);
68                add(fontPanel, c);
69
70        c.weighty = 1.0;
71        c.weightx = 1.0;
72        add(Box.createVerticalGlue(), c);
73        }
74
75        public void savePreferences()
76        {
77                AttributeSet set = fontPanel.getAttributes();
78                Color c;
79                if (set.isDefined(StyleConstants.Foreground))
80                {
81                        c = (Color) set.getAttribute(StyleConstants.Foreground);
82                        Preferences.putInteger("xhtml", "foreground", c.getRGB());
83                }
84                if (set.isDefined(StyleConstants.Background))
85                {
86                        c = (Color) set.getAttribute(StyleConstants.Background);
87                        Preferences.putInteger("xhtml", "background", c.getRGB());
88                }
89                if (set.isDefined(StyleConstants.FontFamily))
90                {
91                        Preferences.putString("xhtml", "font-family", StyleConstants.getFontFamily(set));
92                }
93                if (set.isDefined(StyleConstants.FontSize))
94                {
95                        Preferences.putInteger("xhtml", "font-size", StyleConstants.getFontSize(set));
96                }
97                Preferences.putBoolean("xhtml","bold",StyleConstants.isBold(set));
98                Preferences.putBoolean("xhtml","italic",StyleConstants.isItalic(set));
99        }
100
101}
102/*
103 * Overrides for emacs
104 * Local variables:
105 * tab-width: 4
106 * End:
107 */
Note: See TracBrowser for help on using the repository browser.