Source Code Cross Referenced for WizardPropertyPage.java in  » ERP-CRM-Financial » jmoney » net » sf » jmoney » wizards » 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 » ERP CRM Financial » jmoney » net.sf.jmoney.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * 
003:         */package net.sf.jmoney.wizards;
004:
005:        import java.util.HashMap;
006:        import java.util.Map;
007:
008:        import net.sf.jmoney.model2.ExtendableObject;
009:        import net.sf.jmoney.model2.ExtendablePropertySet;
010:        import net.sf.jmoney.model2.IPropertyControl;
011:        import net.sf.jmoney.model2.ScalarPropertyAccessor;
012:        import net.sf.jmoney.model2.SessionChangeAdapter;
013:
014:        import org.eclipse.jface.wizard.WizardPage;
015:        import org.eclipse.swt.SWT;
016:        import org.eclipse.swt.events.FocusAdapter;
017:        import org.eclipse.swt.events.FocusEvent;
018:        import org.eclipse.swt.events.ModifyEvent;
019:        import org.eclipse.swt.events.ModifyListener;
020:        import org.eclipse.swt.layout.GridData;
021:        import org.eclipse.swt.layout.GridLayout;
022:        import org.eclipse.swt.widgets.Composite;
023:        import org.eclipse.swt.widgets.Label;
024:        import org.eclipse.swt.widgets.Text;
025:        import org.eclipse.ui.PlatformUI;
026:
027:        /**
028:         * A wizard page that contains edit controls for all the properties
029:         * of a given extendable object.
030:         * 
031:         * @author Nigel Westbury
032:         */
033:        public class WizardPropertyPage extends WizardPage {
034:            private ExtendableObject extendableObject;
035:            private ExtendablePropertySet<?> propertySet;
036:            private ScalarPropertyAccessor<String> namePropertyAccessor;
037:
038:            /**
039:             * List of the IPropertyControl objects for the
040:             * properties that can be edited in this panel.
041:             */
042:            private Map<ScalarPropertyAccessor, IPropertyControl> propertyControlList = new HashMap<ScalarPropertyAccessor, IPropertyControl>();
043:
044:            Text nameTextbox;
045:
046:            public WizardPropertyPage(String pageName, String title,
047:                    String message, ExtendableObject extendableObject,
048:                    ExtendablePropertySet<?> propertySet,
049:                    ScalarPropertyAccessor<String> namePropertyAccessor) {
050:                super (pageName);
051:                this .extendableObject = extendableObject;
052:                this .propertySet = propertySet;
053:                this .namePropertyAccessor = namePropertyAccessor;
054:
055:                setTitle(title);
056:                setMessage(message);
057:            }
058:
059:            public void createControl(Composite parent) {
060:                Composite container = new Composite(parent, SWT.NONE);
061:
062:                GridLayout layout = new GridLayout();
063:                layout.numColumns = 2;
064:                container.setLayout(layout);
065:
066:                // Create the controls to edit the properties.
067:
068:                // Add the properties for the Account objects.
069:                for (final ScalarPropertyAccessor<?> propertyAccessor : propertySet
070:                        .getScalarProperties3()) {
071:
072:                    Label propertyLabel = new Label(container, SWT.NONE);
073:                    propertyLabel
074:                            .setText(propertyAccessor.getDisplayName() + ':');
075:                    final IPropertyControl propertyControl = propertyAccessor
076:                            .createPropertyControl(container);
077:
078:                    // Bit of a kludge.  We have special processing for the account
079:                    // name, so save this one.
080:                    if (propertyAccessor == namePropertyAccessor) {
081:                        nameTextbox = (Text) propertyControl.getControl();
082:                    }
083:
084:                    /*
085:                     * If the control factory set up grid data then leave it
086:                     * alone. Otherwise set up the grid data based on the
087:                     * properties minimum sizes and expansion weights. <P> The
088:                     * control widths are set to the minimum width plus 10 times
089:                     * the expansion weight. (As we are not short of space, we
090:                     * make them a little bigger than their minimum sizes). A
091:                     * minimum of 100 pixels is then applied because this makes
092:                     * the right sides of the smaller controls line up, which
093:                     * looks a little more tidy.
094:                     */
095:                    if (propertyControl.getControl().getLayoutData() == null) {
096:                        GridData gridData = new GridData();
097:                        gridData.minimumWidth = propertyAccessor
098:                                .getMinimumWidth();
099:                        gridData.widthHint = Math.max(propertyAccessor
100:                                .getMinimumWidth()
101:                                + 10 * propertyAccessor.getWeight(), 100);
102:                        propertyControl.getControl().setLayoutData(gridData);
103:                    }
104:
105:                    propertyControl.getControl().addFocusListener(
106:                            new FocusAdapter() {
107:                                @Override
108:                                public void focusLost(FocusEvent e) {
109:                                    // TODO: Verify this is needed.  Clean it up?
110:                                    if (extendableObject.getDataManager()
111:                                            .isSessionFiring()) {
112:                                        return;
113:                                    }
114:
115:                                    propertyControl.save();
116:                                }
117:                            });
118:
119:                    // Add to our list of controls.
120:                    propertyControlList.put(propertyAccessor, propertyControl);
121:                }
122:
123:                // Set the values from the object into the control fields.
124:                for (IPropertyControl propertyControl : propertyControlList
125:                        .values()) {
126:                    propertyControl.load(extendableObject);
127:                }
128:
129:                setApplicability();
130:
131:                // This listener code assumes that the applicability of account properties depends only
132:                // on property changes???????
133:                extendableObject.getDataManager().addChangeListener(
134:                        new SessionChangeAdapter() {
135:                            @Override
136:                            public void objectChanged(
137:                                    ExtendableObject changedObject,
138:                                    ScalarPropertyAccessor changedProperty,
139:                                    Object oldValue, Object newValue) {
140:                                setApplicability();
141:                            }
142:                        }, parent);
143:
144:                setPageComplete(false);
145:                nameTextbox.addModifyListener(new ModifyListener() {
146:                    public void modifyText(ModifyEvent e) {
147:                        setPageComplete(nameTextbox.getText().length() != 0);
148:                    }
149:                });
150:
151:                nameTextbox.setFocus();
152:
153:                setControl(container);
154:            }
155:
156:            private void setApplicability() {
157:                for (ScalarPropertyAccessor propertyAccessor : propertyControlList
158:                        .keySet()) {
159:                    IPropertyControl propertyControl = propertyControlList
160:                            .get(propertyAccessor);
161:                    propertyControl.getControl().setEnabled(
162:                            propertyAccessor
163:                                    .isPropertyApplicable(extendableObject));
164:                }
165:            }
166:
167:            @Override
168:            public boolean canFlipToNextPage() {
169:                /*
170:                 * This method controls whether the 'Next' button is enabled.
171:                 */
172:                return nameTextbox.getText().length() != 0;
173:            }
174:
175:            @Override
176:            public void performHelp() {
177:                PlatformUI.getWorkbench().getHelpSystem().displayHelp(
178:                        "net.sf.jmoney.newAccountWizardId");
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.