Source Code Cross Referenced for Toolbar.java in  » XML-UI » xui32 » auction » controller » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML UI » xui32 » auction.controller 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:package auction.controller;
002:
003:import auction.model.Bid;
004:import auction.model.User;
005:import java.util.ArrayList;
006:import java.util.List;
007:import net.xoetrope.optional.annotation.Find;
008:import net.xoetrope.optional.data.pojo.XPojoHelper;
009:import net.xoetrope.optional.data.pojo.XPersistenceController;
010:import net.xoetrope.optional.data.pojo.XPersistentPojoModel;
011:import net.xoetrope.optional.data.pojo.XPojoModel;
012:import net.xoetrope.swing.XButton;
013:import net.xoetrope.swing.XImage;
014:import net.xoetrope.swing.XLabel;
015:import net.xoetrope.swing.toolbar.XToolbar;
016:import net.xoetrope.xui.data.XModel;
017:
018:/**
019: * A toolbar of the application.
020: */
021:public class Toolbar extends XToolbar
022:{
023:  private static final int MYBOOKS_PAGE = 0;
024:  private static final int PROFILE_PAGE = 1;
025:  private static final int SEARCH_PAGE = 2;
026:  private static final int DETAILS_PAGE = 3;
027:  
028:  private int currentPage = -1;  
029:  private List<Integer> navigationHistory;
030:  private int navigationIdx;
031:  
032:  // components
033:  @Find private XLabel userLabel;
034:  @Find private XLabel userNameLabel;
035:  @Find private XButton logOffButton;
036:  @Find private XButton goBackButton, goForwardButton;
037:  @Find private XImage bigIcon;
038:  
039:  private XPersistenceController pojoContext;
040:  private XModel pageNameModel;  
041:  
042:  // transient properties
043:  private XPersistentPojoModel selectedCategoryModel;
044:  private XPersistentPojoModel selectedBookModel;
045:  private XPersistentPojoModel resultListModel;  
046:      
047:  /**
048:   * Creates a new instance of Toolbar
049:   */
050:  public Toolbar()
051:  {
052:    super ();
053:    navigationHistory = new ArrayList<Integer>();
054:    navigationIdx = -1;
055:        
056:    XPojoHelper pojoHelper = new XPojoHelper( rootModel.get( "pojo" ));                    
057:    pojoContext = (XPersistenceController)project.getObject( "PojoContext" );
058:    
059:    // get model references    
060:    pageNameModel = (XModel)rootModel.get( "pageName" );
061:    pageNameModel.set( "Log On" );    
062:    
063:    // get transient property references
064:    selectedCategoryModel = 
065:        (XPersistentPojoModel)pojoHelper.get( "hibernateDAOFactory/categoryDAO/selectedCategory" );
066:    selectedBookModel =
067:        (XPersistentPojoModel)pojoHelper.get( "hibernateDAOFactory/bookDAO/selectedBook" );
068:    resultListModel =
069:        (XPersistentPojoModel)pojoHelper.get( "hibernateDAOFactory/bookDAO/resultListModel" );
070:  }
071:   
072:  // enables/disables navigation buttons
073:  private void setupNavigationButtons()
074:  {
075:    goBackButton.setEnabled( navigationIdx > 0 );
076:    goForwardButton.setEnabled( navigationIdx < navigationHistory.size() - 1 );
077:  }
078:  
079:  /**
080:   * Displays the "MyBooks" page, saves the
081:   * previous page in the navigation history,
082:   * changes icons, etc
083:   */
084:  protected void displayMyBooksPage()
085:  {
086:    pageNameModel.set( "My Books" );
087:    setBigIcon( "mybooks_big.png" );
088:    updateBoundComponentValues();    
089:    pageMgr.showPage( "MyBooks", "content" );
090:    setupNavigationButtons();
091:  }
092:  
093:  protected void displayProfilePage()
094:  {
095:    pageNameModel.set( "Profile" );
096:    setBigIcon( "profile_big.png" );
097:    updateBoundComponentValues();    
098:    pageMgr.showPage( "Profile", "content" );    
099:    setupNavigationButtons();
100:  }
101:  
102:  protected void displaySearchPage()
103:  {
104:    pageNameModel.set( "Search" );
105:    setBigIcon( "search_big.png" );
106:    updateBoundComponentValues();
107:    pageMgr.showPage( "Search", "content" );
108:    setupNavigationButtons();
109:  }
110:  
111:  protected void displayDetailsPage()
112:  {
113:    pageNameModel.set( "Book Details" );
114:    setBigIcon( "details_big.png" );
115:    updateBoundComponentValues();
116:    pageMgr.showPage( "BookDetails", "content" );
117:    setupNavigationButtons();
118:  }
119:  
120:  public void showMyBooksPage()
121:  {
122:    if ( currentPage != MYBOOKS_PAGE ) {
123:      currentPage = MYBOOKS_PAGE;
124:      saveInHistory( currentPage );      
125:      displayMyBooksPage();
126:    }
127:  }
128:  
129:  public void showSearchPage()
130:  {
131:    if ( currentPage != SEARCH_PAGE ) {      
132:      currentPage = SEARCH_PAGE;
133:      saveInHistory( currentPage );      
134:      displaySearchPage();
135:    }
136:  }
137: 
138:  public void showProfilePage()
139:  {
140:    if ( currentPage != PROFILE_PAGE ) {
141:      currentPage = PROFILE_PAGE;
142:      saveInHistory( currentPage );      
143:      displayProfilePage();
144:    }
145:  }
146:
147:  public void showDetailsPage()
148:  {
149:    if ( currentPage != DETAILS_PAGE ) {
150:      currentPage = DETAILS_PAGE;
151:      saveInHistory( currentPage );      
152:      displayDetailsPage();
153:    }
154:  }
155:  
156:  /**
157:   * Saves the specified page in the navigation history
158:   * @param pageType value indicating the page to be saved
159:   */
160:  private void saveInHistory( Integer pageType )
161:  {    
162:    navigationHistory = navigationHistory.subList( 0, ++navigationIdx );    
163:    navigationHistory.add( pageType );    
164:  }
165:      
166:  /**
167:   * Sets the specified icon on the right side of the toolbar
168:   * @param iconName the name of the icon to be set
169:   */
170:  protected void setBigIcon( String iconName )
171:  {
172:    bigIcon.setImageName( iconName );
173:  }
174:
175:  /**
176:   * Logs off the current user, hides the toolbar,
177:   * clears the navigation histroy, displays the Welcome page.
178:   */
179:  public void logOff()
180:  {
181:    // clear transient property nodes
182:    selectedCategoryModel.clear();
183:    selectedBookModel.clear();
184:    resultListModel.clear();
185:    
186:    userLabel.setVisible( false );
187:    userNameLabel.setVisible( false );
188:    logOffButton.setVisible( false );
189:    
190:    XModel currentUserModel = 
191:        (XModel)project.getModel().
192:        get( "pojo/hibernateDAOFactory/userDAO/currentUser" );
193:    currentUserModel.set( new User() );
194:     
195:    pageNameModel.set( "Log On" );
196:    updateBoundComponentValues();
197:    setVisible( false );
198:    pageMgr.showPage( "Welcome", "content" );
199:    navigationHistory.clear();
200:    navigationIdx = -1;
201:    setupNavigationButtons();
202:  }
203:   
204:  /**
205:   * Shows the specified page
206:   * @param pageType the value indicating the page
207:   * to be shown
208:   */
209:  private void showPage( int pageType )
210:  {
211:    switch( pageType ) {
212:      case MYBOOKS_PAGE:
213:        displayMyBooksPage();
214:        break;
215:        
216:      case PROFILE_PAGE:
217:        displayProfilePage();
218:        break;
219:      
220:      case SEARCH_PAGE:
221:        displaySearchPage();
222:        break;
223:        
224:      case DETAILS_PAGE:
225:        displayDetailsPage();
226:        break;
227:    }
228:  }
229:    
230:  /**
231:   * Displays the previous page.
232:   */
233:  public void goBack()
234:  {
235:    currentPage = (int)navigationHistory.get( --navigationIdx );    
236:    showPage( currentPage );
237:    setupNavigationButtons();
238:  }
239:  
240:  /**
241:   * Displays the next page
242:   */
243:  public void goForward()
244:  {
245:    currentPage = (int)navigationHistory.get( ++navigationIdx );
246:    showPage( currentPage );
247:    setupNavigationButtons();
248:  }
249: 
250:}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.