components/visual-panels/core/src/java/vpanels/panel/com/oracle/solaris/vp/panel/swing/timezone/TimeZoneModel.java
equal
deleted
inserted
replaced
18 * |
18 * |
19 * CDDL HEADER END |
19 * CDDL HEADER END |
20 */ |
20 */ |
21 |
21 |
22 /* |
22 /* |
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
23 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. |
24 */ |
24 */ |
25 |
25 |
26 package com.oracle.solaris.vp.panel.swing.timezone; |
26 package com.oracle.solaris.vp.panel.swing.timezone; |
27 |
27 |
28 import com.oracle.solaris.rad.ObjectException; |
28 import com.oracle.solaris.rad.client.RadObjectException; |
|
29 import com.oracle.solaris.rad.client.RadPrivilegeException; |
29 import com.oracle.solaris.vp.panel.common.action.*; |
30 import com.oracle.solaris.vp.panel.common.action.*; |
30 import com.oracle.solaris.vp.panel.common.api.time.HasTimeMXBean; |
31 import com.oracle.solaris.vp.panel.common.api.time.HasTimeBean; |
31 import com.oracle.solaris.vp.panel.common.model.AbstractModel; |
32 import com.oracle.solaris.vp.panel.common.model.AbstractModel; |
32 import com.oracle.solaris.vp.util.misc.finder.Finder; |
33 import com.oracle.solaris.vp.util.misc.finder.Finder; |
33 |
34 |
34 public class TimeZoneModel extends AbstractModel<HasTimeMXBean> { |
35 public class TimeZoneModel extends AbstractModel<HasTimeBean> { |
35 // |
36 // |
36 // Instance data |
37 // Instance data |
37 // |
38 // |
38 |
39 |
39 private static final String DEFAULT_TZ = "US/Pacific"; |
40 private static final String DEFAULT_TZ = "US/Pacific"; |
41 |
42 |
42 // |
43 // |
43 // Constructors |
44 // Constructors |
44 // |
45 // |
45 |
46 |
46 public TimeZoneModel(HasTimeMXBean descriptor) { |
47 public TimeZoneModel(HasTimeBean descriptor) { |
47 super(descriptor); |
48 super(descriptor); |
48 } |
49 } |
49 |
50 |
50 public TimeZoneModel(TimeZoneModel model) { |
51 public TimeZoneModel(TimeZoneModel model) { |
51 super(model.getSource()); |
52 super(model.getSource()); |
65 setTimeZone(DEFAULT_TZ); |
66 setTimeZone(DEFAULT_TZ); |
66 } |
67 } |
67 |
68 |
68 public void load() { |
69 public void load() { |
69 try { |
70 try { |
70 setTimeZone(getSource().getTimeMXBean().getdefaultTimeZone()); |
71 setTimeZone(getSource().getTimeBean().getdefaultTimeZone()); |
71 } catch (ObjectException e) { |
72 } catch (RadObjectException e) { |
72 setTimeZone("UTC"); |
73 setTimeZone("UTC"); |
73 } |
74 } |
74 } |
75 } |
75 |
76 |
76 @Override |
77 @Override |
78 ActionUnauthorizedException { |
79 ActionUnauthorizedException { |
79 |
80 |
80 validate(); |
81 validate(); |
81 |
82 |
82 try { |
83 try { |
83 getSource().getTimeMXBean().setdefaultTimeZone(timeZone); |
84 getSource().getTimeBean().setdefaultTimeZone(timeZone); |
84 |
85 |
85 } catch (SecurityException e) { |
86 } catch (RadPrivilegeException e) { |
86 throw new ActionUnauthorizedException(e); |
87 throw new ActionUnauthorizedException(e); |
87 |
88 |
88 } catch (ObjectException e) { |
89 } catch (RadObjectException e) { |
89 throw new ActionFailedException(Finder.getString( |
90 throw new ActionFailedException(Finder.getString( |
90 "timezone.error.syserror"), e); |
91 "timezone.error.syserror"), e); |
91 } |
92 } |
92 } |
93 } |
93 |
94 |