components/visual-panels/time/src/java/vpanels/app/time/com/oracle/solaris/vp/panels/time/client/swing/TimeModel.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.panels.time.client.swing; |
26 package com.oracle.solaris.vp.panels.time.client.swing; |
27 |
27 |
28 import java.util.Date; |
28 import java.util.Date; |
29 import com.oracle.solaris.rad.ObjectException; |
29 import com.oracle.solaris.rad.client.RadObjectException; |
|
30 import com.oracle.solaris.rad.client.RadPrivilegeException; |
30 import com.oracle.solaris.vp.panel.common.action.*; |
31 import com.oracle.solaris.vp.panel.common.action.*; |
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.panels.time.TimeMXBean; |
33 import com.oracle.solaris.vp.panels.time.Time; |
33 import com.oracle.solaris.vp.util.misc.finder.Finder; |
34 import com.oracle.solaris.vp.util.misc.finder.Finder; |
34 |
35 |
35 public class TimeModel extends AbstractModel<TimePanelDescriptor> { |
36 public class TimeModel extends AbstractModel<TimePanelDescriptor> { |
36 |
37 |
37 private static final long OFFSET_NONE = Long.MAX_VALUE; |
38 private static final long OFFSET_NONE = Long.MAX_VALUE; |
46 // Model methods |
47 // Model methods |
47 // |
48 // |
48 |
49 |
49 public void load() { |
50 public void load() { |
50 try { |
51 try { |
51 offset_ = getSource().getTimeMXBean().gettime().getTime() - |
52 offset_ = getSource().getTimeBean().gettime().getTime() - |
52 System.currentTimeMillis(); |
53 System.currentTimeMillis(); |
53 } catch (ObjectException e) { |
54 } catch (RadObjectException e) { |
54 offset_ = 0; |
55 offset_ = 0; |
55 } |
56 } |
56 } |
57 } |
57 |
58 |
58 public void save() throws ActionFailedException, |
59 public void save() throws ActionFailedException, |
59 ActionUnauthorizedException { |
60 ActionUnauthorizedException { |
60 |
61 |
61 TimeMXBean bean = getSource().getTimeMXBean(); |
62 Time bean = getSource().getTimeBean(); |
62 |
63 |
63 try { |
64 try { |
64 bean.settime(new Date(System.currentTimeMillis() + offset_)); |
65 bean.settime(new Date(System.currentTimeMillis() + offset_)); |
65 |
66 |
66 } catch (SecurityException e) { |
67 } catch (RadPrivilegeException e) { |
67 throw new ActionUnauthorizedException(e); |
68 throw new ActionUnauthorizedException(e); |
68 |
69 |
69 } catch (ObjectException e) { |
70 } catch (RadObjectException e) { |
70 throw new ActionFailedException(Finder.getString( |
71 throw new ActionFailedException(Finder.getString( |
71 "time.time.error.syserror"), e); |
72 "time.time.error.syserror"), e); |
72 } |
73 } |
73 } |
74 } |
74 |
75 |