01: package net.ar.webonswing.tutorial;
02:
03: import net.ar.webonswing.managers.contributors.*;
04: import net.ar.webonswing.managers.persistence.*;
05: import net.ar.webonswing.ui.*;
06: import net.ar.webonswing.visitor.*;
07:
08: public class UserDetailsContributor extends RootPaneUIContributor
09: implements PersistenceContributor {
10: public void accept(Visitor aVisitor) {
11: super .accept(aVisitor);
12:
13: ((ContributorVisitor) aVisitor)
14: .visitPersistenceContributor(this );
15: }
16:
17: public void doPersistenceContribution(
18: PersistenceContributionContainer aPersistenceManager) {
19: UserDetails theWindow = (UserDetails) getJComponent()
20: .getTopLevelAncestor();
21:
22: aPersistenceManager.persistValue(theComponent, new Integer(
23: theWindow.getUser().getId()));
24: }
25:
26: public void restorePersistedValue(
27: PersistenceContributionContainer aPersistenceManager) {
28: UserDetails theWindow = (UserDetails) getJComponent()
29: .getTopLevelAncestor();
30:
31: Integer index = (Integer) aPersistenceManager
32: .restoreValue(theComponent);
33: theWindow.setUser(User.users[index.intValue()]);
34: }
35:
36: public boolean isPersistedValueEqualToModel(
37: PersistenceContributionContainer aPersistenceManager) {
38: return false;
39: }
40: }
|