Source Code Cross Referenced for ResourcePropertySource.java in  » IDE-Eclipse » ui-ide » 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 ide » 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 java.io.File;
013:        import org.eclipse.core.resources.IResource;
014:        import org.eclipse.core.resources.ResourceAttributes;
015:        import org.eclipse.core.runtime.Assert;
016:        import org.eclipse.core.runtime.IPath;
017:        import org.eclipse.jface.viewers.IBasicPropertyConstants;
018:        import org.eclipse.osgi.util.TextProcessor;
019:        import org.eclipse.ui.internal.ide.dialogs.IDEResourceInfoUtils;
020:        import org.eclipse.ui.internal.views.properties.IDEPropertiesMessages;
021:
022:        /**
023:         * A Resource property source.
024:         */
025:        public class ResourcePropertySource implements  IPropertySource {
026:            protected static String NOT_LOCAL_TEXT = IDEPropertiesMessages.PropertySource_notLocal;
027:
028:            protected static String FILE_NOT_FOUND = IDEPropertiesMessages.PropertySource_notFound;
029:
030:            protected static String UNDEFINED_PATH_VARIABLE = IDEPropertiesMessages.PropertySource_undefinedPathVariable;
031:
032:            protected static String FILE_NOT_EXIST_TEXT = IDEPropertiesMessages.PropertySource_fileNotExist;
033:
034:            // The element for the property source
035:            protected IResource element;
036:
037:            // Error message when setting a property incorrectly
038:            protected String errorMessage = IDEPropertiesMessages.PropertySource_readOnly;
039:
040:            // Property Descriptors
041:            static protected IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[7];
042:
043:            static protected IPropertyDescriptor[] propertyDescriptorsLinkVariable = new IPropertyDescriptor[8];
044:            static {
045:                PropertyDescriptor descriptor;
046:
047:                // resource name
048:                descriptor = new PropertyDescriptor(
049:                        IBasicPropertyConstants.P_TEXT,
050:                        IResourcePropertyConstants.P_LABEL_RES);
051:                descriptor.setAlwaysIncompatible(true);
052:                descriptor
053:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
054:                propertyDescriptors[0] = descriptor;
055:                propertyDescriptorsLinkVariable[0] = descriptor;
056:
057:                // Relative path
058:                descriptor = new PropertyDescriptor(
059:                        IResourcePropertyConstants.P_PATH_RES,
060:                        IResourcePropertyConstants.P_DISPLAYPATH_RES);
061:                descriptor.setAlwaysIncompatible(true);
062:                descriptor
063:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
064:                propertyDescriptors[1] = descriptor;
065:                propertyDescriptorsLinkVariable[1] = descriptor;
066:
067:                // readwrite state
068:                descriptor = new PropertyDescriptor(
069:                        IResourcePropertyConstants.P_EDITABLE_RES,
070:                        IResourcePropertyConstants.P_DISPLAYEDITABLE_RES);
071:                descriptor.setAlwaysIncompatible(true);
072:                descriptor
073:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
074:                propertyDescriptors[2] = descriptor;
075:                propertyDescriptorsLinkVariable[2] = descriptor;
076:
077:                // derived state
078:                descriptor = new PropertyDescriptor(
079:                        IResourcePropertyConstants.P_DERIVED_RES,
080:                        IResourcePropertyConstants.P_DISPLAYDERIVED_RES);
081:                descriptor.setAlwaysIncompatible(true);
082:                descriptor
083:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
084:                propertyDescriptors[3] = descriptor;
085:                propertyDescriptorsLinkVariable[3] = descriptor;
086:
087:                // last modified state
088:                descriptor = new PropertyDescriptor(
089:                        IResourcePropertyConstants.P_LAST_MODIFIED_RES,
090:                        IResourcePropertyConstants.P_DISPLAY_LAST_MODIFIED);
091:                descriptor.setAlwaysIncompatible(true);
092:                descriptor
093:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
094:                propertyDescriptors[4] = descriptor;
095:                propertyDescriptorsLinkVariable[4] = descriptor;
096:
097:                // link state
098:                descriptor = new PropertyDescriptor(
099:                        IResourcePropertyConstants.P_LINKED_RES,
100:                        IResourcePropertyConstants.P_DISPLAYLINKED_RES);
101:                descriptor.setAlwaysIncompatible(true);
102:                descriptor
103:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
104:                propertyDescriptors[5] = descriptor;
105:                propertyDescriptorsLinkVariable[5] = descriptor;
106:
107:                // location
108:                descriptor = new PropertyDescriptor(
109:                        IResourcePropertyConstants.P_LOCATION_RES,
110:                        IResourcePropertyConstants.P_DISPLAYLOCATION_RES);
111:                descriptor.setAlwaysIncompatible(true);
112:                descriptor
113:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
114:                propertyDescriptors[6] = descriptor;
115:                propertyDescriptorsLinkVariable[6] = descriptor;
116:
117:                // resolved location
118:                descriptor = new PropertyDescriptor(
119:                        IResourcePropertyConstants.P_RESOLVED_LOCATION_RES,
120:                        IResourcePropertyConstants.P_DISPLAYRESOLVED_LOCATION_RES);
121:                descriptor.setAlwaysIncompatible(true);
122:                descriptor
123:                        .setCategory(IResourcePropertyConstants.P_FILE_SYSTEM_CATEGORY);
124:                propertyDescriptorsLinkVariable[7] = descriptor;
125:
126:            }
127:
128:            /**
129:             * Creates a PropertySource and stores its IResource
130:             *
131:             * @param res the resource for which this is a property source
132:             */
133:            public ResourcePropertySource(IResource res) {
134:                Assert.isNotNull(res);
135:                this .element = res;
136:            }
137:
138:            /* (non-Javadoc)
139:             * Method declared on IPropertySource.
140:             */
141:            public Object getEditableValue() {
142:                return this ;
143:            }
144:
145:            /* (non-Javadoc)
146:             * Method declared on IPropertySource.
147:             */
148:            public IPropertyDescriptor[] getPropertyDescriptors() {
149:                if (isPathVariable(element)) {
150:                    return propertyDescriptorsLinkVariable;
151:                }
152:                return propertyDescriptors;
153:            }
154:
155:            /* (non-Javadoc)
156:             * Method declared on IPropertySource.
157:             */
158:            public Object getPropertyValue(Object name) {
159:                if (name.equals(IBasicPropertyConstants.P_TEXT)) {
160:                    return element.getName();
161:                }
162:                if (name.equals(IResourcePropertyConstants.P_PATH_RES)) {
163:                    return TextProcessor.process(element.getFullPath()
164:                            .toString());
165:                }
166:                if (name.equals(IResourcePropertyConstants.P_LAST_MODIFIED_RES)) {
167:                    return IDEResourceInfoUtils.getDateStringValue(element);
168:                }
169:                if (name.equals(IResourcePropertyConstants.P_EDITABLE_RES)) {
170:                    final ResourceAttributes attributes = element
171:                            .getResourceAttributes();
172:                    if (attributes == null || attributes.isReadOnly()) {
173:                        return IDEPropertiesMessages.ResourceProperty_false;
174:                    }
175:                    return IDEPropertiesMessages.ResourceProperty_true;
176:                }
177:                if (name.equals(IResourcePropertyConstants.P_DERIVED_RES)) {
178:                    if (element.isDerived())
179:                        return IDEPropertiesMessages.ResourceProperty_true;
180:                    return IDEPropertiesMessages.ResourceProperty_false;
181:                }
182:                if (name.equals(IResourcePropertyConstants.P_LINKED_RES)) {
183:                    if (element.isLinked())
184:                        return IDEPropertiesMessages.ResourceProperty_true;
185:                    return IDEPropertiesMessages.ResourceProperty_false;
186:                }
187:                if (name.equals(IResourcePropertyConstants.P_LOCATION_RES)) {
188:                    return TextProcessor.process(IDEResourceInfoUtils
189:                            .getLocationText(element));
190:                }
191:                if (name
192:                        .equals(IResourcePropertyConstants.P_RESOLVED_LOCATION_RES)) {
193:                    return TextProcessor.process(IDEResourceInfoUtils
194:                            .getResolvedLocationText(element));
195:                }
196:                return null;
197:            }
198:
199:            /**
200:             * Returns whether the given resource is a linked resource bound 
201:             * to a path variable.
202:             * 
203:             * @param resource resource to test
204:             * @return boolean <code>true</code> the given resource is a linked 
205:             * 	resource bound to a path variable. <code>false</code> the given 
206:             * 	resource is either not a linked resource or it is not using a
207:             * 	path variable.  
208:             */
209:            private boolean isPathVariable(IResource resource) {
210:                if (!resource.isLinked()) {
211:                    return false;
212:                }
213:
214:                IPath resolvedLocation = resource.getLocation();
215:                if (resolvedLocation == null) {
216:                    // missing path variable
217:                    return true;
218:                }
219:                IPath rawLocation = resource.getRawLocation();
220:                if (resolvedLocation.equals(rawLocation)) {
221:                    return false;
222:                }
223:
224:                return true;
225:            }
226:
227:            /* (non-Javadoc)
228:             * Method declared on IPropertySource.
229:             */
230:            public boolean isPropertySet(Object property) {
231:                return false;
232:            }
233:
234:            /**
235:             * The <code>ResourcePropertySource</code> implementation of this
236:             * <code>IPropertySource</code> method does nothing since all
237:             * properties are read-only.
238:             */
239:            public void resetPropertyValue(Object property) {
240:            }
241:
242:            /**
243:             * The <code>ResourcePropertySource</code> implementation of this
244:             * <code>IPropertySource</code> method does nothing since all
245:             * properties are read-only.
246:             */
247:            public void setPropertyValue(Object name, Object value) {
248:            }
249:
250:            /** 
251:             * Get the java.io.File equivalent of the passed
252:             * IFile. If the location does not exist then return
253:             * <code>null</code>
254:             * @param resource the resource to lookup
255:             * @return java.io.File or <code>null</code>.
256:             */
257:            protected File getFile(IResource resource) {
258:                IPath location = resource.getLocation();
259:                if (location == null) {
260:                    return null;
261:                }
262:                return location.toFile();
263:            }
264:
265:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.