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 m) {
79 String styleName = (String) (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 = (String) (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 = (String) (m.get(Desktop.TTIP_DELAY));
97 try {
98 int delay = Integer.parseInt(tipDelay);
99
146 catch (NumberFormatException e) {
147 complete = false;
148 } // catch
149
150 // default
151 if (!complete){
152 ttDuration.setSelectedItem(tooltipDurations[1]);
153 }
154
155 // make it happen
156 syncTooltipPrefs();
157
158 // save on exit
159 String saveState = (String) (m.get(Desktop.SAVE_ON_EXIT_PREF));
160 saveCheck.setSelected(saveState == null || "true".equalsIgnoreCase(saveState)); // true (null) by default
161 String restoreState = (String) (m.get(Desktop.RESTORE_ON_START_PREF)); // false by default
162 restoreCheck.setSelected(restoreState == null || "true".equalsIgnoreCase(restoreState));
163 }
164
165 @Override
166 public void save(Map m) {
167 ButtonModel bm = styleGrp.getSelection();
168 if (bm != null) {
169 String styleName = bm.getActionCommand();
170 for (int i = 0; i < Desktop.styleNames.length; i++) {
171 if (styleName.equals(Desktop.styleNames[i])) {
172 desktop.setStyle(i);
173 m.put(Desktop.STYLE_PREF, styleName);
174 break;
175 }
176 }
177 }
178
179 boolean tips = ttipsCheck.isSelected();
180 m.put(Desktop.TTIP_PREF, String.valueOf(tips));
181 desktop.setTooltipsEnabled(tips);
182
183 int delay = getTooltipDelay();
184 m.put(Desktop.TTIP_DELAY, Integer.toString(delay));
185 desktop.setTooltipDelay(delay);
186
|
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<?, ?> m) {
79 String styleName = (String)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 = (String) (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 = (String) (m.get(Desktop.TTIP_DELAY));
97 try {
98 int delay = Integer.parseInt(tipDelay);
99
146 catch (NumberFormatException e) {
147 complete = false;
148 } // catch
149
150 // default
151 if (!complete){
152 ttDuration.setSelectedItem(tooltipDurations[1]);
153 }
154
155 // make it happen
156 syncTooltipPrefs();
157
158 // save on exit
159 String saveState = (String) (m.get(Desktop.SAVE_ON_EXIT_PREF));
160 saveCheck.setSelected(saveState == null || "true".equalsIgnoreCase(saveState)); // true (null) by default
161 String restoreState = (String) (m.get(Desktop.RESTORE_ON_START_PREF)); // false by default
162 restoreCheck.setSelected(restoreState == null || "true".equalsIgnoreCase(restoreState));
163 }
164
165 @Override
166 public void save(Map<String, String> m) {
167 ButtonModel bm = styleGrp.getSelection();
168 if (bm != null) {
169 String styleName = bm.getActionCommand();
170 for (int i = 0; i < Desktop.styleNames.length; i++) {
171 if (styleName.equals(Desktop.styleNames[i])) {
172 desktop.setStyle(i);
173 m.put(Desktop.STYLE_PREF, styleName);
174 break;
175 }
176 }
177 }
178
179 boolean tips = ttipsCheck.isSelected();
180 m.put(Desktop.TTIP_PREF, String.valueOf(tips));
181 desktop.setTooltipsEnabled(tips);
182
183 int delay = getTooltipDelay();
184 m.put(Desktop.TTIP_DELAY, Integer.toString(delay));
185 desktop.setTooltipDelay(delay);
186
|