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


001:        package net.xoetrope.swt.demo;
002:
003:        import net.xoetrope.swt.XButton;
004:        import net.xoetrope.swt.XEdit;
005:        import net.xoetrope.swt.XLabel;
006:        import net.xoetrope.swt.XPanel;
007:        import net.xoetrope.swt.XPassword;
008:        import net.xoetrope.swt.XSwtPage;
009:        import net.xoetrope.swt.XTextArea;
010:        import net.xoetrope.swt.XToolBar;
011:        import net.xoetrope.xui.data.XModel;
012:
013:        public class CountryStory extends XSwtPage {
014:
015:            // Constants
016:
017:            public static final int width = 1024 - 14;
018:            public static final int height = 768 - 39 - 19;
019:            public static final int border = 40;
020:
021:            // Attributes
022:
023:            private int xOrigin = 0;
024:            private int yOrigin = 0;
025:            private int widthContent = width - 2 * border;
026:            private int heightContent = height - 2 * border;
027:
028:            private int toolHeight = 0;
029:
030:            private String country;
031:            private String story;
032:
033:            private String username = null;
034:            private String password = null;
035:
036:            private XToolBar shellTB;
037:            private XLabel borderTop, borderLeft, borderRight, borderBottom;
038:            private XPanel storyP, buttonP, editP;
039:            private XTextArea storyTA;
040:            private XEdit usernameE;
041:            private XPassword passwordP;
042:
043:            // Constructor
044:
045:            public CountryStory() {
046:                country = project.getModel().getValueAsString("country");
047:                XModel item = (XModel) project.getModel().get(
048:                        country + "/Informations/story");
049:                story = item.getAttribValueAsString(item.getAttribute("story"));
050:            }
051:
052:            // Automatic Methods
053:
054:            public void pageCreated() {
055:                shellTB = (XToolBar) findComponent("shellTB");
056:                borderTop = (XLabel) findComponent("borderTop");
057:                borderLeft = (XLabel) findComponent("borderLeft");
058:                borderRight = (XLabel) findComponent("borderRight");
059:                borderBottom = (XLabel) findComponent("borderBottom");
060:                initBorders();
061:                storyTA = (XTextArea) findComponent("storyTA");
062:                storyP = (XPanel) findComponent("storyP");
063:                usernameE = (XEdit) findComponent("usernameE");
064:                passwordP = (XPassword) findComponent("passwordP");
065:                buttonP = (XPanel) findComponent("buttonP");
066:                editP = (XPanel) findComponent("editP");
067:                initContent();
068:            }
069:
070:            public void pageActivated() {
071:                storyP.setVisible(true);
072:                //storyB.setVisible( true );
073:            }
074:
075:            // Private Methods
076:
077:            private void initBorders() {
078:                toolHeight = shellTB.getBounds().height;
079:                yOrigin = toolHeight;
080:                heightContent -= toolHeight;
081:                System.out.println("HeightContent : " + heightContent
082:                        + ", widthContent : " + widthContent);
083:                borderTop.setBounds(xOrigin, yOrigin, width, border);
084:                borderLeft.setBounds(xOrigin, yOrigin + border, border,
085:                        heightContent);
086:                borderRight.setBounds(xOrigin + widthContent + border, yOrigin
087:                        + border, border, heightContent);
088:                borderBottom.setBounds(xOrigin, yOrigin + heightContent
089:                        + border, width, border);
090:            }
091:
092:            private void initContent() {
093:                storyTA.setBounds(xOrigin + border, yOrigin + border,
094:                        widthContent, 2 * heightContent / 3);
095:                storyTA.setText(story);
096:                storyP.setBounds(xOrigin + border, yOrigin + border + 2
097:                        * heightContent / 3, widthContent,
098:                        2 * heightContent / 9);
099:                buttonP.setBounds(xOrigin + border, yOrigin + border + 8
100:                        * heightContent / 9, widthContent, heightContent / 9);
101:                editP.setBounds(xOrigin + border, yOrigin + border + 8
102:                        * heightContent / 9, widthContent, heightContent / 9);
103:                setEditMode(false);
104:            }
105:
106:            private void setEditMode(boolean edit) {
107:                storyTA.setEditable(edit);
108:                storyP.setVisible(!edit);
109:                buttonP.setVisible(!edit);
110:                editP.setVisible(edit);
111:                setVisibleLogin(username == null || username.equals(""));
112:            }
113:
114:            private void setVisibleLogin(boolean visible) {
115:                storyP.setVisible(visible);
116:                if (visible)
117:                    storyTA.setBounds(xOrigin + border, yOrigin + border,
118:                            widthContent, 2 * heightContent / 3);
119:                else
120:                    storyTA.setBounds(xOrigin + border, yOrigin + border,
121:                            widthContent, 8 * heightContent / 9);
122:            }
123:
124:            // Events Methods
125:
126:            public void goToPreviousPage() {
127:                reInit();
128:                cancelEdit();
129:                pageMgr.showPrevious();
130:            }
131:
132:            public void goToHomePage() {
133:                reInit();
134:                cancelEdit();
135:                project.getPageManager().showPage("Home");
136:            }
137:
138:            public void editStory() {
139:                if (username == null || username.equals("")) {
140:                    username = usernameE.getText();
141:                    password = passwordP.getText();
142:                }
143:                if (Home.isValidEditor(username, password))
144:                    setEditMode(true);
145:                else {
146:                    reInit();
147:                    showMessage("Identification failed",
148:                            "Your username or password are incorrect !");
149:                }
150:            }
151:
152:            public void saveStory() {
153:                story = storyTA.getText();
154:                setEditMode(false);
155:            }
156:
157:            public void cancelEdit() {
158:                storyTA.setText(story);
159:                setEditMode(false);
160:            }
161:
162:            private void reInit() {
163:                usernameE.setText("");
164:                passwordP.setText("");
165:                username = null;
166:                password = null;
167:            }
168:
169:            //  public void goToNextPage() {
170:            //    MouseEvent me = ( MouseEvent ) getCurrentEvent();
171:            //    System.out.println( "( " + me.x + ", " + me.y + " )" );
172:            //    int hotspotIdx = flag.checkHotspot( me );
173:            //    if( hotspotIdx > -1 ) {
174:            //      String s = flag.getName( hotspotIdx );
175:            //      XSwtPage page = ( XSwtPage )( ( XSwtTarget ) pageMgr.getTarget( "content" ) ).getChildComponent( 0 );
176:            //      String nextPage = ( String ) page.getAttribute( s.toLowerCase(), null );
177:            //      if( nextPage != null )
178:            //        project.getPageManager().showPage( nextPage );
179:            //    }
180:            //  }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.