Source Code Cross Referenced for CountryResults.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 java.util.ArrayList;
004:        import net.xoetrope.optional.data.sql.DatabaseTableModel;
005:        import net.xoetrope.swt.XButton;
006:        import net.xoetrope.swt.XCheckbox;
007:        import net.xoetrope.swt.XComboBox;
008:        import net.xoetrope.swt.XEditTable;
009:        import net.xoetrope.swt.XExpandBar;
010:        import net.xoetrope.swt.XExpandItem;
011:        import net.xoetrope.swt.XImage;
012:        import net.xoetrope.swt.XLabel;
013:        import net.xoetrope.swt.XLink;
014:        import net.xoetrope.swt.XList;
015:        import net.xoetrope.swt.XPanel;
016:        import net.xoetrope.swt.XProgressBar;
017:        import net.xoetrope.swt.XScrollPane;
018:        import net.xoetrope.swt.XSplitPane;
019:        import net.xoetrope.swt.XSwtPage;
020:        import net.xoetrope.swt.XTabPanel;
021:        import net.xoetrope.swt.XTable;
022:        import net.xoetrope.swt.XToolBar;
023:        import net.xoetrope.swt.XTree;
024:        import net.xoetrope.xui.data.XBaseModel;
025:        import net.xoetrope.xui.data.XModel;
026:        import org.eclipse.swt.layout.GridLayout;
027:        import org.eclipse.swt.widgets.Display;
028:
029:        public class CountryResults extends XSwtPage {
030:
031:            // Constants
032:
033:            public static final int width = 1024 - 14;
034:            public static final int height = 768 - 39 - 19;
035:            public static final int border = 40;
036:
037:            // Attributes
038:
039:            private int xOrigin = 0;
040:            private int yOrigin = 0;
041:            private int widthContent = width - 2 * border;
042:            private int heightContent = height - 2 * border;
043:
044:            private int toolHeight = 0;
045:            private int sizeSplit = 0;
046:
047:            private String country;
048:            private String year;
049:            private String club;
050:
051:            private static String[][] competitions = new String[7][2];
052:            private static String[] honours = new String[8];
053:
054:            private XToolBar shellTB;
055:            private XLabel borderTop, borderLeft, borderRight, borderBottom;
056:            private XPanel choiceP, championshipsCupsP, yearChoiceP, clubsP,
057:                    clubChoiceP, clubSearchP, infosP;
058:            private XSplitPane championshipsCupsSP;
059:            private XExpandBar infosEB;
060:            private XExpandItem infosEI;
061:            private XComboBox yearCB;
062:            private XTabPanel competitionsTP;
063:            private XTable compOneT, compTwoT, compThreeT, compFourT,
064:                    compFiveT, compSixT, compSevenT, clubHonoursT, clubSearchT;
065:            private XEditTable infosET;
066:            private XImage infosI;
067:            private XScrollPane infosSP;
068:            private XTree infosT;
069:            private XLink webL;
070:            private XButton addInformationB, setValueInformationB;
071:            // private XProgressBar loadingYearPB;
072:            private XList clubL;
073:            private XCheckbox compOneC, compTwoC, compThreeC, compFourC,
074:                    compFiveC, compSixC, compSevenC, compEightC;
075:
076:            // Constructor
077:
078:            public CountryResults() {
079:                country = project.getModel().getValueAsString("country");
080:                XModel list = (XModel) project.getModel().get(
081:                        country + "/Competitions");
082:                int nb = list.getNumChildren();
083:                for (int i = 0; i < nb; i++) {
084:                    XModel item = list.get(i);
085:                    competitions[i][0] = item.getId();
086:                    competitions[i][1] = item.getAttribValueAsString(item
087:                            .getAttribute("value"));
088:                }
089:                list = (XModel) project.getModel().get(
090:                        country + "/Clubs/Honours");
091:                nb = list.getNumChildren();
092:                for (int i = 0; i < nb; i++) {
093:                    XModel item = list.get(i);
094:                    honours[i] = item.getAttribValueAsString(item
095:                            .getAttribute("value"));
096:                }
097:            }
098:
099:            // Automatic Methods
100:
101:            public void pageCreated() {
102:                shellTB = (XToolBar) findComponent("shellTB");
103:                borderTop = (XLabel) findComponent("borderTop");
104:                borderLeft = (XLabel) findComponent("borderLeft");
105:                borderRight = (XLabel) findComponent("borderRight");
106:                borderBottom = (XLabel) findComponent("borderBottom");
107:                initBorders();
108:                choiceP = (XPanel) findComponent("choiceP");
109:                championshipsCupsP = (XPanel) findComponent("championshipsCupsP");
110:                yearChoiceP = (XPanel) findComponent("yearChoiceP");
111:                yearCB = (XComboBox) findComponent("yearCB");
112:                championshipsCupsSP = (XSplitPane) findComponent("championshipsCupsSP");
113:                competitionsTP = (XTabPanel) findComponent("competitionsTP");
114:                compOneT = (XTable) findComponent("compOneT");
115:                compTwoT = (XTable) findComponent("compTwoT");
116:                compThreeT = (XTable) findComponent("compThreeT");
117:                compFourT = (XTable) findComponent("compFourT");
118:                compFiveT = (XTable) findComponent("compFiveT");
119:                compSixT = (XTable) findComponent("compSixT");
120:                compSevenT = (XTable) findComponent("compSevenT");
121:                infosP = (XPanel) findComponent("infosP");
122:                infosEB = (XExpandBar) findComponent("infosEB");
123:                infosEI = (XExpandItem) findComponent("infosEI");
124:                infosI = (XImage) findComponent("infosI");
125:                infosSP = (XScrollPane) findComponent("infosSP");
126:                infosET = (XEditTable) findComponent("infosET");
127:                infosT = (XTree) findComponent("infosT");
128:                addInformationB = (XButton) findComponent("addInformationB");
129:                setValueInformationB = (XButton) findComponent("setValueInformationB");
130:                webL = (XLink) findComponent("webL");
131:                // loadingYearPB = ( XProgressBar ) findComponent( "loadingYearPB" );
132:                clubsP = (XPanel) findComponent("clubsP");
133:                clubChoiceP = (XPanel) findComponent("clubChoiceP");
134:                clubL = (XList) findComponent("clubL");
135:                clubSearchP = (XPanel) findComponent("clubSearchP");
136:                compOneC = (XCheckbox) findComponent("compOneC");
137:                compTwoC = (XCheckbox) findComponent("compTwoC");
138:                compThreeC = (XCheckbox) findComponent("compThreeC");
139:                compFourC = (XCheckbox) findComponent("compFourC");
140:                compFiveC = (XCheckbox) findComponent("compFiveC");
141:                compSixC = (XCheckbox) findComponent("compSixC");
142:                compSevenC = (XCheckbox) findComponent("compSevenC");
143:                compEightC = (XCheckbox) findComponent("compEightC");
144:                clubHonoursT = (XTable) findComponent("clubHonoursT");
145:                clubSearchT = (XTable) findComponent("clubSearchT");
146:                initContent();
147:            }
148:
149:            public void pageActivated() {
150:            }
151:
152:            // Private Methods
153:
154:            private void initBorders() {
155:                toolHeight = shellTB.getBounds().height;
156:                yOrigin = toolHeight;
157:                heightContent -= toolHeight;
158:                System.out.println("HeightContent : " + heightContent
159:                        + ", widthContent : " + widthContent);
160:                borderTop.setBounds(xOrigin, yOrigin, width, border);
161:                borderLeft.setBounds(xOrigin, yOrigin + border, border,
162:                        heightContent);
163:                borderRight.setBounds(xOrigin + widthContent + border, yOrigin
164:                        + border, border, heightContent);
165:                borderBottom.setBounds(xOrigin, yOrigin + heightContent
166:                        + border, width, border);
167:            }
168:
169:            private void initContent() {
170:                choiceP.setBounds(xOrigin + border, yOrigin + border,
171:                        widthContent, heightContent / 10);
172:                championshipsCupsP.setBounds(xOrigin + border, yOrigin + border
173:                        + heightContent / 10, widthContent,
174:                        9 * heightContent / 10);
175:                yearChoiceP.setBounds(0, 0, widthContent, heightContent / 10);
176:                yearCB.setSize(widthContent / 5, yearCB.getSize().y);
177:                championshipsCupsSP.setBounds(0, heightContent / 10,
178:                        widthContent, 4 * heightContent / 5);
179:                sizeSplit = championshipsCupsSP.getSizeSplit();
180:                competitionsTP
181:                        .setBounds(0, 0, 2 * widthContent / 3 - sizeSplit,
182:                                4 * heightContent / 5);
183:                compOneT.setBounds(0, 0, 2 * widthContent / 3 - sizeSplit - 13,
184:                        4 * heightContent / 5 - 25);
185:                compTwoT.setBounds(0, 0, 2 * widthContent / 3 - sizeSplit - 13,
186:                        4 * heightContent / 5 - 25);
187:                compThreeT.setBounds(0, 0, 2 * widthContent / 3 - sizeSplit
188:                        - 13, 4 * heightContent / 5 - 25);
189:                compFourT.setBounds(0, 0,
190:                        2 * widthContent / 3 - sizeSplit - 13,
191:                        4 * heightContent / 5 - 25);
192:                compFiveT.setBounds(0, 0,
193:                        2 * widthContent / 3 - sizeSplit - 13,
194:                        4 * heightContent / 5 - 25);
195:                compSixT.setBounds(0, 0, 2 * widthContent / 3 - sizeSplit - 13,
196:                        4 * heightContent / 5 - 25);
197:                compSevenT.setBounds(0, 0, 2 * widthContent / 3 - sizeSplit
198:                        - 13, 4 * heightContent / 5 - 25);
199:                setTabPanelsTitle();
200:                infosP.setSize(widthContent / 3, 4 * heightContent / 5);
201:                infosEB.setSize(widthContent / 3, 4 * heightContent / 5);
202:                infosEI.setSize(widthContent / 3, 4 * heightContent / 5);
203:                int widthImage = widthContent / 5;
204:                int heightImage = 3 * heightContent / 10;
205:                int widthScroll = widthContent / 3 - 20;
206:                int heightScroll = 3 * heightContent / 10;
207:                infosI.setBounds(widthContent / 15, 5, widthImage, heightImage);
208:                infosSP.setBounds(8, heightImage + 10, widthScroll,
209:                        heightScroll);
210:                infosET.setBounds(0, 0, widthScroll, 2 * heightScroll);
211:                infosT.setBounds(0, 0, widthScroll, 2 * heightScroll);
212:                addInformationB.setBounds(8, heightImage + heightScroll + 25,
213:                        widthScroll / 2 - 5, heightContent / 20);
214:                setValueInformationB.setBounds(widthScroll / 2 + 13,
215:                        heightImage + heightScroll + 25, widthScroll / 2 - 5,
216:                        heightContent / 20);
217:                webL.setBounds(8, heightImage + heightScroll + heightContent
218:                        / 20 + 40, widthScroll, heightContent / 20);
219:                // loadingYearPB.setBounds( 0, heightContent / 10, widthContent, 4 * heightContent / 5 );
220:                // loadingYearPB.setMaximum( 6000 );
221:                clubsP.setBounds(xOrigin + border, yOrigin + border
222:                        + heightContent / 10, widthContent,
223:                        9 * heightContent / 10);
224:                clubChoiceP.setBounds(0, 0, 7 * widthContent / 16,
225:                        3 * heightContent / 10);
226:                GridLayout lay = (GridLayout) clubChoiceP.getLayout();
227:                clubL.setSize(widthContent / 4 - 2 * lay.marginWidth,
228:                        heightContent / 5 - lay.marginHeight);
229:                clubSearchP.setBounds(7 * widthContent / 16, 0,
230:                        5 * widthContent / 8, 3 * heightContent / 10);
231:                clubHonoursT.setBounds(0, 3 * heightContent / 10, widthContent,
232:                        3 * heightContent / 5);
233:                clubSearchT.setBounds(0, 3 * heightContent / 10, widthContent,
234:                        3 * heightContent / 5);
235:            }
236:
237:            private void setTabPanelsTitle() {
238:                int nb = competitionsTP.getItemCount();
239:                for (int i = 0; i < nb; i++)
240:                    competitionsTP.getItem(i).setText(competitions[i][1]);
241:            }
242:
243:            // Binding Methods
244:
245:            public String getSeasons() {
246:                return country + "/Seasons";
247:            }
248:
249:            public String getCompOne() {
250:                return country + "/" + year + "/" + competitions[0][0];
251:            }
252:
253:            public String getCompTwo() {
254:                return country + "/" + year + "/" + competitions[1][0];
255:            }
256:
257:            public String getCompThree() {
258:                return country + "/" + year + "/" + competitions[2][0];
259:            }
260:
261:            public String getCompFour() {
262:                return country + "/" + year + "/" + competitions[3][0];
263:            }
264:
265:            public String getCompFive() {
266:                return country + "/" + year + "/" + competitions[4][0];
267:            }
268:
269:            public String getCompSix() {
270:                return country + "/" + year + "/" + competitions[5][0];
271:            }
272:
273:            public String getCompSeven() {
274:                return country + "/" + year + "/" + competitions[6][0];
275:            }
276:
277:            public String getClubs() {
278:                return country + "/Clubs/List";
279:            }
280:
281:            public String getHonours() {
282:                if (club == null)
283:                    ((DatabaseTableModel) rootModel.get("honours")).getTable()
284:                            .retrieve("Club=\'" + "xxx" + "\'");
285:                return "honours";
286:            }
287:
288:            public String getSearch() {
289:                return "search";
290:            }
291:
292:            // Content Methods
293:
294:            public String getLocationSplit() {
295:                return "" + 2 * widthContent / 3;
296:            }
297:
298:            public String getHonourOne() {
299:                return honours[0];
300:            }
301:
302:            public String getHonourTwo() {
303:                return honours[1];
304:            }
305:
306:            public String getHonourThree() {
307:                return honours[2];
308:            }
309:
310:            public String getHonourFour() {
311:                return honours[3];
312:            }
313:
314:            public String getHonourFive() {
315:                return honours[4];
316:            }
317:
318:            public String getHonourSix() {
319:                return honours[5];
320:            }
321:
322:            public String getHonourSeven() {
323:                return honours[6];
324:            }
325:
326:            public String getHonourEight() {
327:                return honours[7];
328:            }
329:
330:            // Events Methods
331:
332:            public void goToPreviousPage() {
333:                //reInit();
334:                //setEditMode( false );
335:                pageMgr.showPrevious();
336:            }
337:
338:            public void goToHomePage() {
339:                project.getPageManager().showPage("Home");
340:            }
341:
342:            public void reloadBindings() {
343:                updateBindings();
344:            }
345:
346:            public void showChampsCups() {
347:                clubsP.setVisible(false);
348:                championshipsCupsP.setVisible(true);
349:            }
350:
351:            public void showClubs() {
352:                championshipsCupsP.setVisible(false);
353:                clubsP.setVisible(true);
354:            }
355:
356:            public void showYear() {
357:                //    championshipsCupsSP.setVisible( false );
358:                //    loadingYearPB.setVisible( true );
359:                //    final XProgressBar bar = loadingYearPB;
360:                //    final int maximum =  loadingYearPB.getMaximum();
361:                //    final Display display = getDisplay();
362:                //    final long tf = System.currentTimeMillis() + maximum;
363:                //    new Thread() {
364:                //      public void run() {
365:                //        while( System.currentTimeMillis() < tf ) {
366:                //          if( display.isDisposed() )
367:                //            return;
368:                //          display.asyncExec( new Runnable() {
369:                //            public void run() {
370:                //              if( bar.isDisposed() )
371:                //                return;
372:                //              int nb = Integer.parseInt( "" + ( maximum - tf + System.currentTimeMillis() ) );
373:                //              System.out.println( "Nombre : " + nb );
374:                //              bar.setSelection( nb );
375:                //            }
376:                //          } );
377:                //        }
378:                //      }
379:                //    }.start();
380:                year = (String) yearCB.getSelectedObject();
381:                updateBinding(getBinding(compOneT));
382:                updateBinding(getBinding(compTwoT));
383:                updateBinding(getBinding(compThreeT));
384:                updateBinding(getBinding(compFourT));
385:                updateBinding(getBinding(compFiveT));
386:                updateBinding(getBinding(compSixT));
387:                updateBinding(getBinding(compSevenT));
388:                showCompInfos();
389:                //loadingYearPB.setVisible( false );
390:                championshipsCupsSP.setVisible(true);
391:            }
392:
393:            public void showCompInfos() {
394:                int index = competitionsTP.getSelectionIndex();
395:                String competition = competitionsTP.getItem(index).getText();
396:                XBaseModel parentMdl = (XBaseModel) project.getModel().get(
397:                        country + "/CompetitionsStory");
398:                boolean exists = parentMdl.getChildExists(competition);
399:                if (exists) {
400:                    XModel competitionModel = (XModel) project.getModel().get(
401:                            country + "/CompetitionsStory/" + competition);
402:                    infosEI.setAttribute("content", competition);
403:                    infosI.setAttribute("content", "countries/"
404:                            + country.toLowerCase()
405:                            + "/logos/"
406:                            + competitionModel
407:                                    .getAttribValueAsString(competitionModel
408:                                            .getAttribute("image")));
409:                    infosT.setModel(competitionModel);
410:                    setCompVisible(true);
411:                    webL.setText(competitionModel
412:                            .getAttribValueAsString(competitionModel
413:                                    .getAttribute("web")));
414:                }
415:            }
416:
417:            public void showClubInfos() {
418:                int index = competitionsTP.getSelectionIndex();
419:                XTable table = (XTable) (((XPanel) competitionsTP
420:                        .getItem(index).getControl()).getChildren()[0]);
421:                index = table.getSelectionIndex();
422:                String club = table.getItem(index).getText();
423:                XBaseModel parentMdl = (XBaseModel) project.getModel().get(
424:                        country + "/Clubs");
425:                boolean exists = parentMdl.getChildExists(club);
426:                if (exists) {
427:                    XModel clubModel = (XModel) project.getModel().get(
428:                            country + "/Clubs/" + club);
429:                    infosEI.setAttribute("content", club);
430:                    infosI.setAttribute("content", "countries/"
431:                            + country.toLowerCase()
432:                            + "/logos/"
433:                            + clubModel.getAttribValueAsString(clubModel
434:                                    .getAttribute("image")));
435:                    infosET.setModel(clubModel);
436:                    infosET.update();
437:                    setCompVisible(false);
438:                    webL.setText(clubModel.getAttribValueAsString(clubModel
439:                            .getAttribute("web")));
440:                }
441:            }
442:
443:            public void showSearchResult() {
444:                clubHonoursT.setVisible(false);
445:                clubSearchT.setVisible(true);
446:                String sqlWhere = "";
447:                ArrayList list = new ArrayList();
448:                if (compOneC.getSelection())
449:                    list.add(compOneC.getText());
450:                if (compTwoC.getSelection())
451:                    list.add(compTwoC.getText());
452:                if (compThreeC.getSelection())
453:                    list.add(compThreeC.getText());
454:                if (compFourC.getSelection())
455:                    list.add(compFourC.getText());
456:                if (compFiveC.getSelection())
457:                    list.add(compFiveC.getText());
458:                if (compSixC.getSelection())
459:                    list.add(compSixC.getText());
460:                if (compSevenC.getSelection())
461:                    list.add(compSevenC.getText());
462:                if (compEightC.getSelection())
463:                    list.add(compEightC.getText());
464:                int nb = list.size();
465:                if (nb > 0) {
466:                    sqlWhere += "( Club IN ( SELECT Club FROM Honours WHERE ( Competition IN ( \'"
467:                            + (String) list.get(0) + "\'";
468:                    for (int i = 1; i < nb; i++)
469:                        sqlWhere += ", \'" + (String) list.get(i) + "\'";
470:                    sqlWhere += " ) ) GROUP BY Club HAVING ( COUNT ( * ) = "
471:                            + nb + " ) ) ) AND ( Competition IN ( \'"
472:                            + (String) list.get(0) + "\'";
473:                    for (int i = 1; i < nb; i++)
474:                        sqlWhere += ", \'" + (String) list.get(i) + "\'";
475:                    sqlWhere += " ) )";
476:                }
477:                System.out.println(sqlWhere);
478:                DatabaseTableModel table = (DatabaseTableModel) rootModel
479:                        .get("search");
480:                table.getTable().retrieve(sqlWhere);
481:                updateBinding(getBinding(clubSearchT));
482:            }
483:
484:            private void setCompVisible(boolean visible) {
485:                infosT.setVisible(visible);
486:                infosET.setVisible(!visible);
487:                infosET.setHeaderVisible(false);
488:                infosET.setLinesVisible(false);
489:                addInformationB.setVisible(!visible);
490:                setValueInformationB.setVisible(!visible);
491:            }
492:
493:            public void addInformation() {
494:                infosET.showDialogAddItem("Add an information");
495:            }
496:
497:            public void setValueInformation() {
498:                infosET
499:                        .showDialogSetValueColumnItem("Set a new value to an information");
500:            }
501:
502:            public void showClubHonours() {
503:                clubSearchT.setVisible(false);
504:                clubHonoursT.setVisible(true);
505:                club = (String) clubL.getSelectedObject();
506:                DatabaseTableModel table = (DatabaseTableModel) rootModel
507:                        .get("honours");
508:                table.getTable().retrieve("Club=\'" + club + "\'");
509:                updateBinding(getBinding(clubHonoursT));
510:            }
511:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.