Source Code Cross Referenced for FieldBehavior.java in  » Net » Terracotta » org » terracotta » dso » editors » chooser » 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 » Net » Terracotta » org.terracotta.dso.editors.chooser 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003:         * notice. All rights reserved.
004:         */
005:        package org.terracotta.dso.editors.chooser;
006:
007:        import org.eclipse.jdt.core.IClassFile;
008:        import org.eclipse.jdt.core.ICompilationUnit;
009:        import org.eclipse.jdt.core.IField;
010:        import org.eclipse.jdt.core.IJavaElement;
011:        import org.eclipse.jdt.core.IJavaProject;
012:        import org.eclipse.jdt.core.IPackageFragment;
013:        import org.eclipse.jdt.core.IPackageFragmentRoot;
014:        import org.eclipse.jdt.core.IType;
015:        import org.eclipse.jdt.core.JavaModelException;
016:        import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
017:        import org.eclipse.jface.viewers.ISelectionChangedListener;
018:        import org.eclipse.jface.viewers.SelectionChangedEvent;
019:        import org.eclipse.jface.viewers.StructuredSelection;
020:        import org.eclipse.jface.viewers.Viewer;
021:        import org.eclipse.jface.viewers.ViewerFilter;
022:        import org.eclipse.swt.SWT;
023:
024:        import java.util.ArrayList;
025:        import java.util.Iterator;
026:        import java.util.List;
027:
028:        public final class FieldBehavior implements  NavigatorBehavior {
029:
030:            public static final String ADD_MSG = "Enter Fully Qualified Field Name";
031:            private static final String SELECT_FIELD = "Select Member Field";
032:            private final List m_selectedValues;
033:
034:            public FieldBehavior() {
035:                this .m_selectedValues = new ArrayList();
036:            }
037:
038:            public int style() {
039:                return SWT.MULTI;
040:            }
041:
042:            public String getTitle() {
043:                return SELECT_FIELD;
044:            }
045:
046:            public ViewerFilter getFilter(final IJavaProject javaProject) {
047:                return new ViewerFilter() {
048:                    public boolean select(Viewer viewer, Object parentElement,
049:                            Object element) {
050:                        if (element instanceof  IJavaProject)
051:                            return true;
052:                        if (element instanceof  ClassPathContainer
053:                                || element instanceof  ICompilationUnit
054:                                || element instanceof  IType
055:                                || element instanceof  IPackageFragmentRoot
056:                                || element instanceof  IClassFile
057:                                || element instanceof  IField) {
058:                            return true;
059:                        }
060:                        if (element instanceof  IPackageFragment) {
061:                            try {
062:                                return ((IPackageFragment) element)
063:                                        .containsJavaResources();
064:                            } catch (JavaModelException jme) {/**/
065:                            }
066:                        }
067:                        return false;
068:                    }
069:                };
070:            }
071:
072:            public ISelectionChangedListener getSelectionChangedListener(
073:                    final PackageNavigator nav) {
074:                return new ISelectionChangedListener() {
075:                    public void selectionChanged(SelectionChangedEvent event) {
076:                        m_selectedValues.removeAll(m_selectedValues);
077:                        StructuredSelection selection = (StructuredSelection) event
078:                                .getSelection();
079:                        List selectedFields = new ArrayList();
080:                        if (!selection.isEmpty()) {
081:                            Object element;
082:                            for (Iterator i = selection.iterator(); i.hasNext();) {
083:                                if ((element = i.next()) instanceof  IField) {
084:                                    IField field = (IField) element;
085:                                    m_selectedValues
086:                                            .add(resolveFullName(field));
087:                                    selectedFields.add(element);
088:                                }
089:                            }
090:                        }
091:                        if (selectedFields.size() > 0)
092:                            nav.okButtonEnabled(true);
093:                        else
094:                            nav.okButtonEnabled(false);
095:                    }
096:                };
097:            }
098:
099:            private String resolveFullName(IJavaElement field) {
100:                List list = new ArrayList();
101:                list.add(field.getElementName());
102:                IJavaElement javaPart = field.getParent();
103:                while (javaPart != null) {
104:                    if (javaPart.getElementType() == IJavaElement.TYPE
105:                            || javaPart.getElementType() == IJavaElement.PACKAGE_FRAGMENT
106:                            || javaPart.getElementType() == IJavaElement.PACKAGE_DECLARATION) {
107:                        list.add(javaPart.getElementName());
108:
109:                    }
110:                    javaPart = javaPart.getParent();
111:                }
112:                String[] parts = (String[]) list.toArray(new String[0]);
113:                StringBuffer name = new StringBuffer();
114:                for (int i = parts.length - 1; i >= 1; i--) {
115:                    name.append(parts[i] + ".");
116:                }
117:                name.append(parts[0]);
118:                return name.toString();
119:            }
120:
121:            public Object getValues() {
122:                return m_selectedValues.toArray(new String[0]);
123:            }
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.