Source Code Cross Referenced for StreetAddress.java in  » IDE-Eclipse » ui-examples » org » eclipse » ui » examples » propertysheet » 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 » IDE Eclipse » ui examples » org.eclipse.ui.examples.propertysheet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.examples.propertysheet;
011:
012:        import java.util.Vector;
013:
014:        import org.eclipse.ui.views.properties.IPropertyDescriptor;
015:        import org.eclipse.ui.views.properties.IPropertySource;
016:        import org.eclipse.ui.views.properties.TextPropertyDescriptor;
017:
018:        /**
019:         * PropertySource containing street information pertenant to Address
020:         */
021:        public class StreetAddress implements  IPropertySource {
022:
023:            //properties
024:            private Integer buildNo;
025:
026:            private String aptBox;
027:
028:            private String streetName;
029:
030:            //default property values
031:            private static final Integer BUILD_NO_DEFAULT = new Integer(0);
032:
033:            private static final String APTBOX_DEFAULT = MessageUtil
034:                    .getString("unspecified"); //$NON-NLS-1$
035:
036:            private static final String STREETNAME_DEFAULT = MessageUtil
037:                    .getString("unspecified"); //$NON-NLS-1$
038:
039:            //property unique keys
040:            public static final String P_ID_BUILD_NO = "Street.buildingNo"; //$NON-NLS-1$
041:
042:            public static final String P_ID_APTBOX = "Street.aptNo"; //$NON-NLS-1$
043:
044:            public static final String P_ID_STREET = "Street.street"; //$NON-NLS-1$
045:
046:            //property display keys
047:            public static final String P_BUILD_NO = MessageUtil
048:                    .getString("building_number"); //$NON-NLS-1$
049:
050:            public static final String P_APTBOX = MessageUtil
051:                    .getString("apt.no_or_box.no"); //$NON-NLS-1$
052:
053:            public static final String P_STREET = MessageUtil
054:                    .getString("street"); //$NON-NLS-1$
055:
056:            //
057:            private static Vector descriptors;
058:
059:            static {
060:                descriptors = new Vector();
061:                descriptors.addElement(new TextPropertyDescriptor(
062:                        P_ID_BUILD_NO, P_BUILD_NO));
063:                descriptors.addElement(new TextPropertyDescriptor(P_ID_APTBOX,
064:                        P_APTBOX));
065:                descriptors.addElement(new TextPropertyDescriptor(P_ID_STREET,
066:                        P_STREET));
067:            }
068:
069:            /**
070:             * Street Default Constructor.
071:             */
072:            public StreetAddress() {
073:                super ();
074:            }
075:
076:            /**
077:             * Convenience Street constructor. AptBox set to default
078:             */
079:            public StreetAddress(int buildNo, String streetName) {
080:                super ();
081:                setBuildNo(new Integer(buildNo));
082:                setStreetName(streetName);
083:            }
084:
085:            /**
086:             * Convenience Street constructor.
087:             */
088:            public StreetAddress(int buildNo, String aptBox, String streetName) {
089:                super ();
090:                setBuildNo(new Integer(buildNo));
091:                setAptBox(aptBox);
092:                setStreetName(streetName);
093:            }
094:
095:            /* (non-Javadoc)
096:             * Method declared on Object
097:             */
098:            public boolean equals(Object ob) {
099:                return toString().equals(ob.toString());
100:            }
101:
102:            /**
103:             * the appartment number
104:             */
105:            private String getAptBox() {
106:                if (aptBox == null)
107:                    aptBox = APTBOX_DEFAULT;
108:                return aptBox;
109:            }
110:
111:            /**
112:             * Returns the building number
113:             */
114:            private Integer getBuildNo() {
115:                if (buildNo == null)
116:                    buildNo = BUILD_NO_DEFAULT;
117:                return buildNo;
118:            }
119:
120:            /**
121:             * Returns the descriptors
122:             */
123:            private static Vector getDescriptors() {
124:                return descriptors;
125:            }
126:
127:            /* (non-Javadoc)
128:             * Method declared on IPropertySource
129:             */
130:            public Object getEditableValue() {
131:                return this .toString();
132:            }
133:
134:            /* (non-Javadoc)
135:             * Method declared on IPropertySource
136:             */
137:            public IPropertyDescriptor[] getPropertyDescriptors() {
138:                return (IPropertyDescriptor[]) getDescriptors().toArray(
139:                        new IPropertyDescriptor[getDescriptors().size()]);
140:            }
141:
142:            /** 
143:             * The <code>Name</code> implementation of this
144:             * <code>IPropertySource</code> method returns the following properties
145:             *
146:             * 	1) P_BUILD_NO returns java.lang.Integer
147:             * 	2) P_APTBOX returns java.lang.String
148:             *	3) P_STREET returns java.lang.String
149:             */
150:            public Object getPropertyValue(Object propKey) {
151:                if (propKey.equals(P_ID_BUILD_NO))
152:                    return getBuildNo().toString();
153:                if (propKey.equals(P_ID_APTBOX))
154:                    return getAptBox();
155:                if (propKey.equals(P_ID_STREET))
156:                    return getStreetName();
157:                return null;
158:            }
159:
160:            /**
161:             * Returns the street name
162:             */
163:            private String getStreetName() {
164:                if (streetName == null)
165:                    streetName = STREETNAME_DEFAULT;
166:                return streetName;
167:            }
168:
169:            /* (non-Javadoc)
170:             * Method declared on Object
171:             */
172:            public int hashCode() {
173:                return toString().hashCode();
174:            }
175:
176:            /* (non-Javadoc)
177:             * Method declared on IPropertySource
178:             */
179:            public boolean isPropertySet(Object property) {
180:                if (property.equals(P_ID_BUILD_NO))
181:                    return getBuildNo() != BUILD_NO_DEFAULT;
182:                if (property.equals(P_ID_APTBOX))
183:                    return getAptBox() != APTBOX_DEFAULT;
184:                if (property.equals(P_ID_STREET))
185:                    return getStreetName() != STREETNAME_DEFAULT;
186:                return false;
187:            }
188:
189:            /* (non-Javadoc)
190:             * Method declared on IPropertySource
191:             */
192:            public void resetPropertyValue(Object property) {
193:                if (property.equals(P_ID_BUILD_NO)) {
194:                    setBuildNo(BUILD_NO_DEFAULT);
195:                    return;
196:                }
197:                if (property.equals(P_ID_APTBOX)) {
198:                    setAptBox(APTBOX_DEFAULT);
199:                    return;
200:                }
201:                if (property.equals(P_ID_STREET)) {
202:                    setStreetName(STREETNAME_DEFAULT);
203:                    return;
204:                }
205:            }
206:
207:            /**
208:             * Sets the appartment number
209:             */
210:            private void setAptBox(String newAptBox) {
211:                aptBox = newAptBox;
212:            }
213:
214:            /**
215:             * Sets the building number
216:             */
217:            private void setBuildNo(Integer newBuildNo) {
218:                buildNo = newBuildNo;
219:            }
220:
221:            /** 
222:             * The <code>Name</code> implementation of this
223:             * <code>IPropertySource</code> method 
224:             * defines the following Setable properties
225:             *
226:             * 	1) P_BUILD_NO expects java.lang.Integer
227:             * 	2) P_APTBOX expects java.lang.String
228:             *	3) P_STREET expects java.lang.String
229:             */
230:            public void setPropertyValue(Object name, Object value) {
231:                if (name.equals(P_ID_BUILD_NO)) {
232:                    try {
233:                        setBuildNo(new Integer(Integer.parseInt((String) value)));
234:                    } catch (NumberFormatException e) {
235:                        setBuildNo(BUILD_NO_DEFAULT);
236:                    }
237:                    return;
238:                }
239:                if (name.equals(P_ID_APTBOX)) {
240:                    setAptBox((String) value);
241:                    return;
242:                }
243:                if (name.equals(P_ID_STREET)) {
244:                    setStreetName((String) value);
245:                    return;
246:                }
247:            }
248:
249:            /**
250:             * Sets the street name
251:             */
252:            private void setStreetName(String newStreetName) {
253:                streetName = newStreetName;
254:            }
255:
256:            /**
257:             * The value as displayed in the Property Sheet. Will not print default values
258:             * @return java.lang.String
259:             */
260:            public String toString() {
261:                StringBuffer outStringBuffer = new StringBuffer();
262:                if (!getAptBox().equals(APTBOX_DEFAULT)) {
263:                    outStringBuffer.append(getAptBox());
264:                    outStringBuffer.append(", "); //$NON-NLS-1$
265:                }
266:                if (!getBuildNo().equals(BUILD_NO_DEFAULT)) {
267:                    outStringBuffer.append(getBuildNo());
268:                    outStringBuffer.append(" "); //$NON-NLS-1$
269:                }
270:                if (!getStreetName().equals(STREETNAME_DEFAULT)) {
271:                    outStringBuffer.append(getStreetName());
272:                }
273:                return outStringBuffer.toString();
274:            }
275:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.