Source Code Cross Referenced for PropertyDescriptor.java in  » IDE-Eclipse » ui » org » eclipse » ui » views » properties » 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 » org.eclipse.ui.views.properties 
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.views.properties;
011:
012:        import org.eclipse.core.runtime.Assert;
013:        import org.eclipse.jface.viewers.CellEditor;
014:        import org.eclipse.jface.viewers.ICellEditorValidator;
015:        import org.eclipse.jface.viewers.ILabelProvider;
016:        import org.eclipse.jface.viewers.LabelProvider;
017:        import org.eclipse.swt.widgets.Composite;
018:
019:        /**
020:         * Standard implementation for property descriptors.
021:         * <p>
022:         * The required attributes of property descriptors (id and display name) are
023:         * passed to the constructor; the optional attributes can be configured using
024:         * the various set methods (all have reasonable default values):
025:         * <ul>
026:         *   <li><code>setDescription</code></li>
027:         *   <li><code>setCategory</code></li>
028:         *   <li><code>setLabelProvider</code></li>
029:         *   <li><code>setHelpContexts</code></li>
030:         * </ul>
031:         * Subclasses should reimplement <code>getPropertyEditor</code> to provide a
032:         * cell editor for changing the value; otherwise the property will be 
033:         * effectively read only.
034:         * </p>
035:         * <p>
036:         * There are several concrete subclasses provided in this package that cover
037:         * the most common cases:
038:         * <ul>
039:         *   <li><code>TextPropertyDescriptor</code> - edits with a 
040:         *      <code>TextCellEditor</code></li>
041:         *   <li><code>ComboBoxPropertyDescriptor - edits with a
042:         *      <code>ComboBoxCellEditor</code></code></li>
043:         *   <li><code>ColorPropertyDescriptor - edits with a 
044:         *      <code>ColorCellEditor</code></code></li>
045:         * </ul>
046:         * </p>
047:         */
048:        public class PropertyDescriptor implements  IPropertyDescriptor {
049:
050:            /**
051:             * The property id.
052:             */
053:            private Object id;
054:
055:            /**
056:             * The name to display for the property.
057:             */
058:            private String display;
059:
060:            /**
061:             * Category name, or <code>null</code> if none (the default).
062:             */
063:            private String category = null;
064:
065:            /**
066:             * Description of the property, or <code>null</code> if none (the default). 
067:             */
068:            private String description = null;
069:
070:            /**
071:             * The help context ids, or <code>null</code> if none (the default). 
072:             */
073:            private Object helpIds;
074:
075:            /**
076:             * The flags used to filter the property.
077:             */
078:            private String[] filterFlags;
079:
080:            /**
081:             * The object that provides the property value's text and image, or 
082:             * <code>null</code> if the default label provider is used (the default).
083:             */
084:            private ILabelProvider labelProvider = null;
085:
086:            /**
087:             * The object to validate the values in the cell editor, or <code>null</code>
088:             * if none (the default).
089:             */
090:            private ICellEditorValidator validator;
091:
092:            /**
093:             * Indicates if the descriptor is compatible with other descriptors of this
094:             * type. <code>false</code> by default.
095:             */
096:            private boolean incompatible = false;
097:
098:            /**
099:             * Creates a new property descriptor with the given id and display name
100:             */
101:            public PropertyDescriptor(Object id, String displayName) {
102:                Assert.isNotNull(id);
103:                Assert.isNotNull(displayName);
104:                this .id = id;
105:                this .display = displayName;
106:            }
107:
108:            /**
109:             * The <code>PropertyDescriptor</code> implementation of this 
110:             * <code>IPropertyDescriptor</code> method returns <code>null</code>.
111:             * <p>
112:             * Since no cell editor is returned, the property is read only.
113:             * </p>
114:             */
115:            public CellEditor createPropertyEditor(Composite parent) {
116:                return null;
117:            }
118:
119:            /**
120:             * Returns <code>true</code> if this property descriptor is to be always 
121:             * considered incompatible with any other property descriptor.
122:             * This prevents a property from displaying during multiple 
123:             * selection.
124:             *
125:             * @return <code>true</code> to indicate always incompatible
126:             */
127:            protected boolean getAlwaysIncompatible() {
128:                return incompatible;
129:            }
130:
131:            /**
132:             * The <code>PropertyDescriptor</code> implementation of this 
133:             * <code>IPropertyDescriptor</code> method returns the value set by
134:             * the <code>setCategory</code> method. If unset, this method returns
135:             * <code>null</code> indicating the default category.
136:             *
137:             * @see #setCategory
138:             */
139:            public String getCategory() {
140:                return category;
141:            }
142:
143:            /**
144:             * The <code>PropertyDescriptor</code> implementation of this 
145:             * <code>IPropertyDescriptor</code> method returns the value set by
146:             * the <code>setDescription</code> method. If unset, this method returns
147:             * <code>null</code> indicating no description.
148:             *
149:             * @see #setDescription
150:             */
151:            public String getDescription() {
152:                return description;
153:            }
154:
155:            /**
156:             * The <code>SimplePropertyDescriptor</code> implementation of this 
157:             * <code>IPropertyDescriptor</code> method returns the value supplied
158:             * on the constructor.
159:             */
160:            public String getDisplayName() {
161:                return display;
162:            }
163:
164:            /**
165:             * The <code>SimplePropertyDescriptor</code> implementation of this 
166:             * <code>IPropertyDescriptor</code> method returns the value set by
167:             * the <code>setFilterFlags</code> method. If unset, this method returns
168:             * <code>null</code>.
169:             * <p>
170:             * Valid values for these flags are declared as constants on 
171:             *  <code>IPropertySheetEntry</code>
172:             */
173:            public String[] getFilterFlags() {
174:                return filterFlags;
175:            }
176:
177:            /**
178:             * The <code>SimplePropertyDescriptor</code> implementation of this 
179:             * <code>IPropertyDescriptor</code> method returns the value set by
180:             * the <code>setHelpContextId</code> method. If unset, this method returns
181:             * <code>null</code>.
182:             *
183:             * @see #setHelpContextIds
184:             */
185:            public Object getHelpContextIds() {
186:                return helpIds;
187:            }
188:
189:            /**
190:             * The <code>PropertyDescriptor</code> implementation of this 
191:             * <code>IPropertyDescriptor</code> method returns the value supplied
192:             * on the constructor.
193:             */
194:            public Object getId() {
195:                return id;
196:            }
197:
198:            /**
199:             * The <code>PropertyDescriptor</code> implementation of this 
200:             * <code>IPropertyDescriptor</code> method returns the value set by
201:             * the <code>setProvider</code> method or, if no value has been set
202:             * it returns a <code>LabelProvider</code>
203:             *
204:             * @see #setLabelProvider
205:             */
206:            public ILabelProvider getLabelProvider() {
207:                if (labelProvider != null) {
208:                    return labelProvider;
209:                } else {
210:                    return new LabelProvider();
211:                }
212:            }
213:
214:            /**
215:             * Returns the input validator for editing the property.
216:             *
217:             * @return the validator used to verify correct values for this property,
218:             *   or <code>null</code>
219:             */
220:            protected ICellEditorValidator getValidator() {
221:                return validator;
222:            }
223:
224:            /** 
225:             * Returns whether a label provider has been set on the receiver.
226:             * @return whether a label provider has been set on the receiver.
227:             * @see #setLabelProvider
228:             * @since 3.0
229:             */
230:            public boolean isLabelProviderSet() {
231:                return labelProvider != null;
232:            }
233:
234:            /**
235:             * The <code>SimplePropertyDescriptor</code> implementation of this 
236:             * <code>IPropertyDescriptor</code> method returns true if the other
237:             * property has the same id and category and <code>getAlwaysIncompatible()</code>
238:             * returns false
239:             */
240:            public boolean isCompatibleWith(IPropertyDescriptor anotherProperty) {
241:                if (getAlwaysIncompatible()) {
242:                    return false;
243:                }
244:
245:                // Compare id		
246:                Object id1 = getId();
247:                Object id2 = anotherProperty.getId();
248:                if (!id1.equals(id2)) {
249:                    return false;
250:                }
251:
252:                // Compare Category (may be null)
253:                if (getCategory() == null) {
254:                    if (anotherProperty.getCategory() != null) {
255:                        return false;
256:                    }
257:                } else {
258:                    if (!getCategory().equals(anotherProperty.getCategory())) {
259:                        return false;
260:                    }
261:                }
262:
263:                return true;
264:            }
265:
266:            /**
267:             * Sets a flag indicating whether this property descriptor is to be always 
268:             * considered incompatible with any other property descriptor.
269:             * Setting this flag prevents a property from displaying during multiple 
270:             * selection.
271:             *
272:             * @param flag <code>true</code> to indicate always incompatible
273:             */
274:            public void setAlwaysIncompatible(boolean flag) {
275:                incompatible = flag;
276:            }
277:
278:            /**
279:             * Sets the category for this property descriptor.
280:             * 
281:             * @param category the category for the descriptor, or <code>null</code> if none
282:             * @see #getCategory
283:             */
284:            public void setCategory(String category) {
285:                this .category = category;
286:            }
287:
288:            /**
289:             * Sets the description for this property descriptor.
290:             * The description should be limited to a single line so that it can be
291:             * displayed in the status line.
292:             * 
293:             * @param description the description, or <code>null</code> if none
294:             * @see #getDescription
295:             */
296:            public void setDescription(String description) {
297:                this .description = description;
298:            }
299:
300:            /**
301:             * Sets the the filter flags for this property descriptor.
302:             * The description should be limited to a single line so that it can be
303:             * displayed in the status line.
304:             * <p>
305:             * Valid values for these flags are declared as constants on 
306:             *  <code>IPropertySheetEntry</code>
307:             * </p>
308:             * 
309:             * @param value the filter flags
310:             * @see #getFilterFlags
311:             */
312:            public void setFilterFlags(String value[]) {
313:                filterFlags = value;
314:            }
315:
316:            /**
317:             * Sets the help context id for this property descriptor.
318:             *
319:             * NOTE: Help support system API's changed since 2.0 and arrays
320:             * of contexts are no longer supported.
321:             * </p>
322:             * <p>
323:             * Thus the only valid parameter type for this method
324:             * is a <code>String</code> representing a context id. 
325:             * The previously valid parameter types are deprecated. 
326:             * The plural name for this method is unfortunate.
327:             * </p>
328:             * 
329:             * @param contextIds the help context ids, or <code>null</code> if none
330:             * @see #getHelpContextIds
331:             */
332:            public void setHelpContextIds(Object contextIds) {
333:                helpIds = contextIds;
334:            }
335:
336:            /**
337:             * Sets the label provider for this property descriptor.
338:             * <p>
339:             * If no label provider is set an instance of <code>LabelProvider</code>
340:             * will be created as the default when needed.
341:             * </p>
342:             * 
343:             * @param provider the label provider for the descriptor, or 
344:             *   <code>null</code> if the default label provider should be used
345:             * @see #getLabelProvider
346:             */
347:            public void setLabelProvider(ILabelProvider provider) {
348:                labelProvider = provider;
349:            }
350:
351:            /**
352:             * Sets the input validator for the cell editor for this property descriptor.
353:             * <p>
354:             * [Issue: This method should be unnecessary is the cell editor's own
355:             *  validator is used.
356:             * ]
357:             * </p>
358:             * 
359:             * @param validator the cell input validator, or <code>null</code> if none
360:             */
361:            public void setValidator(ICellEditorValidator validator) {
362:                this.validator = validator;
363:            }
364:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.