Source Code Cross Referenced for Welcome.java in  » XML-UI » xui32 » com » xoetrope » xbb » 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 » com.xoetrope.xbb 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:package com.xoetrope.xbb;
002:
003:import java.awt.Color;
004:import java.awt.event.ActionEvent;
005:import java.awt.event.ActionListener;
006:import java.util.Enumeration;
007:import java.util.Hashtable;
008:import java.util.Properties;
009:import java.util.prefs.Preferences;
010:import javax.swing.JComponent;
011:import javax.swing.SwingUtilities;
012:import javax.swing.Timer;
013:import javax.swing.border.LineBorder;
014:
015:import net.xoetrope.optional.annotation.Find;
016:
017:import net.xoetrope.swing.XButton;
018:import net.xoetrope.swing.XComboBox;
019:import net.xoetrope.swing.XImageButton;
020:import net.xoetrope.swing.XLabel;
021:import net.xoetrope.swing.XPanel;
022:import net.xoetrope.swing.XTabPanel;
023:import net.xoetrope.swing.app.XDockingApp;
024:import net.xoetrope.swing.docking.XDockable;
025:import net.xoetrope.swing.util.XGraphicsUtils;
026:
027:import net.xoetrope.xui.XPage;
028:import net.xoetrope.xui.XPageManager;
029:
030:import net.xoetrope.xui.data.XModel;
031:
032:import com.xoetrope.data.DatabasePreparationTask;
033:import com.xoetrope.data.PreparationListener;
034:import com.xoetrope.xbb.modules.ModuleManager;
035:
036:import com.xoetrope.swing.tabs.WrappingTabComponent;
037:import com.xoetrope.swing.helper.FadeInHelper;
038:
039:
040:/**
041: * A welcome page for XBB. The page performs some inital setup for languages
042: * and database loading
043: * <p> Copyright (c) Xoetrope Ltd., 2001-2007, This software is licensed under
044: * the GNU Public License (GPL), please see license.txt for more details. If
045: * you make commercial use of this software you must purchase a commercial
046: * license from Xoetrope.</p>
047: * @author luano
048: */
049:public class Welcome extends XPage implements  PreparationListener
050:{    
051:  public static final boolean DEBUG = true;
052:  
053:  // Version numbering
054:  public static final String BUILD_NUMBER = "18";
055:  public static final String VERSION_NUMBER = "0";
056:  public static final String DATABASE_VERSION_NUMBER = "112";
057:
058:  // Activation control
059:  private static boolean splashActivated = false;
060:  private static boolean prepared = false;
061:
062:  static Object connector;
063:  private int tickCount;
064:  private Timer timer;
065:
066:  // Langage switch members
067:  private Hashtable languages;
068:  private String selectedLanguage;
069:  private String defLangCode;
070:  private static boolean inChangeLang = false;    
071:  
072:  private XDockingApp dockingApp;
073:  
074:  private FadeInHelper animationHelper;
075:  
076:  @Find private XComboBox languageCombo;
077:  @Find private XLabel loadingStatus, versionLabel, dbVersionLabel;
078:  @Find private XButton loginBtn;
079:  @Find private XTabPanel infoPanels;
080:  @Find private XPanel guidesPanel, infoPanel;
081:  
082:  /** Creates a new instance of Welcome */
083:  public Welcome() 
084:  {
085:    Preferences dptPrefs = Preferences.userNodeForPackage( getClass());
086:    defLangCode = dptPrefs.get( "defaultLanguage", "en" );
087:    project.setStartupParam( "Language", defLangCode );
088:    pageHelper.componentFactory.setResourceBundle( defLangCode );
089:
090:    dockingApp = (XDockingApp)project.getAppFrame();
091:    dockingApp.showExclusive( this , true );
092:    
093:    animationHelper = new FadeInHelper();
094:    animationHelper.setAnaimationValueInc( 0.025F );
095:  }
096:    
097:  public void pageCreated()
098:  {
099:    tickCount = 0;
100:    infoPanel.setBorder( new LineBorder( Color.white, 10 ));
101:    guidesPanel.setBorder( new LineBorder( Color.white, 10 ));
102://    infoPanels.setTabComponentAt( 0, new WrappingTabComponent( project, infoPanels, true ));
103://    infoPanels.setTabComponentAt( 1, new WrappingTabComponent( project, infoPanels, true ));
104:
105:    SwingUtilities.invokeLater( new Runnable() 
106:    {
107:      public void run() 
108:      {    
109:        XModel root = project.getModel();
110:        if ( DEBUG ) {
111:          root.set( "rs3/versionLabel", VERSION_NUMBER + "." + BUILD_NUMBER );
112:          versionLabel.setText( VERSION_NUMBER + "." + BUILD_NUMBER );
113:        }
114:        else {
115:          root.set( "rs3/versionLabel", VERSION_NUMBER );
116:          ((XLabel)findComponent( "versionLabel" )).setText( VERSION_NUMBER );
117:        }
118:        
119:        root.set( "rs3/dbVersionLabel", DATABASE_VERSION_NUMBER );
120:        dbVersionLabel.setText( DATABASE_VERSION_NUMBER );
121:
122:        root.set( "rs3/buildVersionLabel", BUILD_NUMBER );
123:
124:        // Setup the language list
125:        fillLanguageList();
126:      }
127:    });
128:
129:    // Create a timer to show the status message and then hide it
130:    timer = new Timer( 1000, new ActionListener() 
131:    {
132:      public void actionPerformed( ActionEvent evt ) 
133:      {
134:        if ( connector != null ) {
135:          // Wait three seconds
136:          if ( tickCount++ > 2 ) {
137:            timer.stop();
138:            loadingStatus.setText( "" );
139:          }
140:        }
141:        else 
142:          loadingStatus.setText( loadingStatus.getText() + "." );
143:      }    
144:    });        
145:    timer.start();
146:    
147:    DatabasePreparationTask dbt = new DatabasePreparationTask();
148:    dbt.prepare( project, this , "DATABASE_VERSION" );
149:    
150:    project.getPageManager().mapPageName( "START_PAGE", "Welcome" );  
151:  }
152:  
153:  public void pageAdded()
154:  {    
155:    dockingApp = (XDockingApp)project.getAppFrame();
156:    dockingApp.showExclusive( this , true );
157:  }
158:  
159:  public void pageActivated()
160:  {    
161:    changeLanguage();
162:  }
163:  
164:  /**
165:   * Read the language file and fill the language list
166:   */
167:  private void fillLanguageList()
168:  {
169:    try {
170:      inChangeLang = true;
171:      languages = new Hashtable();
172:      
173:      Properties props = new Properties();
174:      String selectedLanguageName = null;
175:      props.load( project.getInputStream( "LanguageList.properties" ));
176:      Enumeration propNames = props.propertyNames();
177:      while ( propNames.hasMoreElements() ) {
178:        String languageName = (String)propNames.nextElement();
179:        String languageCode = (String)props.get( languageName );
180:        if ( languageCode.equals( defLangCode ))
181:          selectedLanguageName = languageName;
182:        languages.put( languageName, languageCode );
183:        languageCombo.addItem( languageName );
184:      }
185:      if ( selectedLanguageName != null )
186:        languageCombo.select( (Object)selectedLanguageName );
187:      inChangeLang = false;
188:    }
189:    catch ( Exception ex ) {
190:    }
191:  }
192:        
193:  /**
194:   * Respond to a change in the language list by resetting the language
195:   */    
196:  public void changeLanguage()
197:  {
198:    if ( !inChangeLang )  {
199:      inChangeLang = true;
200:      String language = (String)languageCombo.getSelectedItem();
201:      if ( language != null ) {
202:        defLangCode = (String)languages.get( language );
203:        Preferences dptPrefs = Preferences.userNodeForPackage( getClass());
204:        dptPrefs.put( "defaultLanguage", defLangCode );
205:        project.setStartupParam( "Language", defLangCode );
206:
207:        pageHelper.componentFactory.setResourceBundle( defLangCode );
208:        XPageManager pm = project.getPageManager();
209:        pm.reset();
210:        pm.showPage( "Welcome" );
211:        updateBoundComponentValues();
212:      }
213:      inChangeLang = false;
214:    }
215:  }
216:  
217:  /**
218:   * Login to the applications
219:   */
220:  public void login()
221:  {
222:    ModuleManager.getInstance();
223:    dockingApp.showExclusive( this , false );
224:    XDockable dockable = dockingApp.findDockable( this  );
225:    dockable.header.getParent().setVisible( false );
226:    showPage( "AccountSummary", "content" );
227:  }
228:
229:  /**
230:   * The info panel tab selection has changed
231:   */
232:  public void tabChanged()
233:  {
234:    int idx = infoPanels.getSelectedIndex();
235:    animationHelper.animate( (JComponent)findComponent( "infoPanel" + ( idx + 1 ) + "top" ));
236:  }
237:  
238:  /**
239:   * Is the listener ready to receive the preparred object?
240:   * @return true if the listener is ready for input
241:   */
242:  public boolean isReady()
243:  {
244:    return ( getStatus() >= XPage.ACTIVATED );
245:  }
246:  
247:  /**
248:   * The preparation, the database load, is complete and the login should be enabled
249:   * @param o the prepared object
250:   */
251:  public void preparationCompleted( Object obj )
252:  {
253:    loginBtn.setEnabled( true );
254:    XGraphicsUtils.vibrate( loginBtn );
255:    
256:    connector = obj;
257:    loadingStatus.setText( project.getTranslator().translate( "Ready" ));
258:  }
259:  
260:  /**
261:   * An error was detected while performng the preparation task
262:   * @param msg an error message
263:   */
264:  public void preparationFailed( String msg )
265:  {
266:    loginBtn.setEnabled( false );
267:    timer.stop();
268:    loadingStatus.setText( project.getTranslator().translate( msg + ", please contact the administrator" ));
269:  }
270:}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.