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


001:        /***************************************************************************************************
002:         * Copyright (c) 2006 IBM Corporation and others. All rights reserved. This program and the
003:         * accompanying materials are made available under the terms of the Eclipse Public License v1.0
004:         * which accompanies this distribution, and is available at
005:         * http://www.eclipse.org/legal/epl-v10.html
006:         * 
007:         * Contributors: IBM Corporation - initial API and implementation
008:         **************************************************************************************************/package org.eclipse.ui.navigator;
009:
010:        import java.util.Set;
011:
012:        import org.eclipse.jface.viewers.TreePath;
013:        import org.eclipse.jface.viewers.TreePathViewerSorter;
014:        import org.eclipse.jface.viewers.Viewer;
015:        import org.eclipse.jface.viewers.ViewerSorter;
016:        import org.eclipse.ui.internal.navigator.NavigatorContentService;
017:
018:        /**
019:         * 
020:         * Provides an implementation of TreeViewerSorter that uses the given parent to determine the
021:         * correct sort order based on the defined
022:         * <b>org.eclipse.ui.navigator.navigatorContent/navigatorContent/commonSorter</b> elements
023:         * available in the set of <i>visible</i> content extensions.
024:         * 
025:         * <p>
026:         * The CommonViewerSorter must be assigned a {@link INavigatorContentService} to drive its sorting
027:         * algorithm. Without a vaild content service, the sorter will return the default ordering.
028:         * </p>
029:         * <p>
030:         * A CommonViewerSorter may not be attached to more than one CommonViewer.
031:         * </p>
032:         * 
033:         * <p>
034:         * Clients may not extend this class.
035:         * </p>
036:         * 
037:         * 
038:         * 
039:         * @since 3.2
040:         * 
041:         */
042:        public final class CommonViewerSorter extends TreePathViewerSorter {
043:
044:            private NavigatorContentService contentService;
045:
046:            private INavigatorSorterService sorterService;
047:
048:            /**
049:             * Create a sorter service attached to the given content service.
050:             * 
051:             * @param aContentService
052:             *            The content service used by the viewer that will use this sorter service.
053:             * @since 3.3
054:             */
055:            public void setContentService(
056:                    INavigatorContentService aContentService) {
057:                contentService = (NavigatorContentService) aContentService;
058:                sorterService = contentService.getSorterService();
059:            }
060:
061:            /*
062:             * (non-Javadoc)
063:             * 
064:             * @see org.eclipse.jface.viewers.ViewerSorter#category(java.lang.Object)
065:             */
066:            public int category(Object element) {
067:                if (contentService == null)
068:                    return 0;
069:
070:                INavigatorContentDescriptor source = contentService
071:                        .getSourceOfContribution(element);
072:                if (source == null)
073:                    source = getSource(element);
074:                return source != null ? source.getPriority()
075:                        : Priority.NORMAL_PRIORITY_VALUE;
076:            }
077:
078:            public int compare(Viewer viewer, TreePath parentPath, Object e1,
079:                    Object e2) {
080:                if (contentService == null)
081:                    return -1;
082:                INavigatorContentDescriptor sourceOfLvalue = contentService
083:                        .getSourceOfContribution(e1);
084:                INavigatorContentDescriptor sourceOfRvalue = contentService
085:                        .getSourceOfContribution(e2);
086:
087:                if (sourceOfLvalue == null)
088:                    sourceOfLvalue = getSource(e1);
089:                if (sourceOfRvalue == null)
090:                    sourceOfRvalue = getSource(e2);
091:
092:                // identity comparison
093:                if (sourceOfLvalue != null && sourceOfLvalue == sourceOfRvalue) {
094:                    Object parent;
095:                    if (parentPath == null) {
096:                        parent = viewer.getInput();
097:                    } else {
098:                        parent = parentPath.getLastSegment();
099:                    }
100:                    ViewerSorter sorter = sorterService.findSorter(
101:                            sourceOfLvalue, parent, e1, e2);
102:                    if (sorter != null) {
103:                        return sorter.compare(viewer, e1, e2);
104:                    }
105:                }
106:                int categoryDelta = category(e1) - category(e2);
107:                if (categoryDelta == 0) {
108:                    return super .compare(viewer, e1, e2);
109:                }
110:                return categoryDelta;
111:            }
112:
113:            private INavigatorContentDescriptor getSource(Object o) {
114:                Set descriptors = contentService
115:                        .findDescriptorsWithPossibleChild(o);
116:                if (descriptors != null && descriptors.size() > 0) {
117:                    return (INavigatorContentDescriptor) descriptors.iterator()
118:                            .next();
119:                }
120:                return null;
121:            }
122:
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.