16 * version 2 for more details (a copy is included in the LICENSE file that
17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27 package com.sun.javatest.tool;
28
29 import java.awt.Component;
30 import java.awt.GridBagConstraints;
31 import java.awt.GridBagLayout;
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.util.Enumeration;
35 import java.util.Map;
36 import javax.swing.plaf.basic.BasicComboBoxRenderer;
37 import javax.swing.Box;
38 import javax.swing.ButtonGroup;
39 import javax.swing.ButtonModel;
40 import javax.swing.JCheckBox;
41 import javax.swing.JComboBox;
42 import javax.swing.JLabel;
43 import javax.swing.JList;
44 import javax.swing.JPanel;
45 import javax.swing.JRadioButton;
46
47 /**
48 * Preferences for the desktop itself.
49 */
50 class DesktopPrefsPane extends PreferencesPane {
51 DesktopPrefsPane(Desktop desktop, UIFactory uif) {
52 this.desktop = desktop;
53 this.uif = uif;
54 setHelp("ui.prefs.appearance.csh");
55 setLayout(new GridBagLayout());
56 GridBagConstraints c = new GridBagConstraints();
57 c.fill = GridBagConstraints.HORIZONTAL;
58 c.gridwidth = GridBagConstraints.REMAINDER;
59 c.weightx = 1;
60 c.insets.bottom= 10; // set off subsequent entries
61
62 //add(createDesktopStylePanel(), c);
63 styleGrp = new ButtonGroup(); // to avoid NPE
64
65 add(createToolTipsPanel(), c);
66 add(createShutdownPanel(), c);
67
68 c.fill = GridBagConstraints.BOTH;
69 c.weighty = 1;
70 add(Box.createVerticalGlue(), c);
71 }
72
73 public String getText() {
74 return uif.getI18NString("dt.prefs.name");
75 }
76
77 @Override
78 public void load(Map<String, String> m) {
79 String styleName = m.get(Desktop.STYLE_PREF);
80 if (styleName == null)
81 styleName = Desktop.styleNames[desktop.getStyle()];
82
83 for (Enumeration e = styleGrp.getElements(); e.hasMoreElements(); ) {
84 JRadioButton rb = (JRadioButton)e.nextElement();
85 if (rb.getActionCommand().equals(styleName)) {
86 rb.setSelected(true);
87 break;
88 }
89 }
90 // tooltips
91 String tipState = m.get(Desktop.TTIP_PREF);
92 ttipsCheck.setSelected(tipState == null || tipState.equalsIgnoreCase("true"));
93
94 boolean complete = false; // used for delay and duration code
95
96 String tipDelay = m.get(Desktop.TTIP_DELAY);
97 try {
98 int delay = Integer.parseInt(tipDelay);
99
100 if (delay == Desktop.TTIP_DELAY_NONE) {
101 // no delay
102 ttDelay.setSelectedItem(tooltipDelays[0]);
103 complete = true;
|
16 * version 2 for more details (a copy is included in the LICENSE file that
17 * accompanied this code).
18 *
19 * You should have received a copy of the GNU General Public License version
20 * 2 along with this work; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24 * or visit www.oracle.com if you need additional information or have any
25 * questions.
26 */
27 package com.sun.javatest.tool;
28
29 import java.awt.Component;
30 import java.awt.GridBagConstraints;
31 import java.awt.GridBagLayout;
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.util.Enumeration;
35 import java.util.Map;
36 import javax.swing.*;
37 import javax.swing.plaf.basic.BasicComboBoxRenderer;
38
39 /**
40 * Preferences for the desktop itself.
41 */
42 class DesktopPrefsPane extends PreferencesPane {
43 DesktopPrefsPane(Desktop desktop, UIFactory uif) {
44 this.desktop = desktop;
45 this.uif = uif;
46 setHelp("ui.prefs.appearance.csh");
47 setLayout(new GridBagLayout());
48 GridBagConstraints c = new GridBagConstraints();
49 c.fill = GridBagConstraints.HORIZONTAL;
50 c.gridwidth = GridBagConstraints.REMAINDER;
51 c.weightx = 1;
52 c.insets.bottom= 10; // set off subsequent entries
53
54 //add(createDesktopStylePanel(), c);
55 styleGrp = new ButtonGroup(); // to avoid NPE
56
57 add(createToolTipsPanel(), c);
58 add(createShutdownPanel(), c);
59
60 c.fill = GridBagConstraints.BOTH;
61 c.weighty = 1;
62 add(Box.createVerticalGlue(), c);
63 }
64
65 public String getText() {
66 return uif.getI18NString("dt.prefs.name");
67 }
68
69 @Override
70 public void load(Map<String, String> m) {
71 String styleName = m.get(Desktop.STYLE_PREF);
72 if (styleName == null)
73 styleName = Desktop.styleNames[desktop.getStyle()];
74
75 for (Enumeration<AbstractButton> e = styleGrp.getElements(); e.hasMoreElements(); ) {
76 JRadioButton rb = (JRadioButton)e.nextElement();
77 if (rb.getActionCommand().equals(styleName)) {
78 rb.setSelected(true);
79 break;
80 }
81 }
82 // tooltips
83 String tipState = m.get(Desktop.TTIP_PREF);
84 ttipsCheck.setSelected(tipState == null || tipState.equalsIgnoreCase("true"));
85
86 boolean complete = false; // used for delay and duration code
87
88 String tipDelay = m.get(Desktop.TTIP_DELAY);
89 try {
90 int delay = Integer.parseInt(tipDelay);
91
92 if (delay == Desktop.TTIP_DELAY_NONE) {
93 // no delay
94 ttDelay.setSelectedItem(tooltipDelays[0]);
95 complete = true;
|