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


001:        /*******************************************************************************
002:         * Copyright (c) 2006, 2007 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.internal.quickaccess;
011:
012:        import org.eclipse.jface.resource.ImageDescriptor;
013:
014:        /**
015:         * @since 3.3
016:         * 
017:         */
018:        public abstract class QuickAccessElement {
019:
020:            private static final int[][] EMPTY_INDICES = new int[0][0];
021:            private QuickAccessProvider provider;
022:
023:            /**
024:             * @param provider
025:             */
026:            public QuickAccessElement(QuickAccessProvider provider) {
027:                super ();
028:                this .provider = provider;
029:            }
030:
031:            /**
032:             * Returns the label to be displayed to the user.
033:             * 
034:             * @return the label
035:             */
036:            public abstract String getLabel();
037:
038:            /**
039:             * Returns the image descriptor for this element.
040:             * 
041:             * @return an image descriptor, or null if no image is available
042:             */
043:            public abstract ImageDescriptor getImageDescriptor();
044:
045:            /**
046:             * Returns the id for this element. The id has to be unique within the
047:             * QuickAccessProvider that provided this element.
048:             * 
049:             * @return the id
050:             */
051:            public abstract String getId();
052:
053:            /**
054:             * Executes the associated action for this element.
055:             */
056:            public abstract void execute();
057:
058:            /**
059:             * Return the label to be used for sorting and matching elements.
060:             * 
061:             * @return the sort label
062:             */
063:            public String getSortLabel() {
064:                return getLabel();
065:            }
066:
067:            /**
068:             * @return Returns the provider.
069:             */
070:            public QuickAccessProvider getProvider() {
071:                return provider;
072:            }
073:
074:            /**
075:             * @param filter
076:             * @return
077:             */
078:            public QuickAccessEntry match(String filter,
079:                    QuickAccessProvider providerForMatching) {
080:                String sortLabel = getLabel();
081:                int index = sortLabel.toLowerCase().indexOf(filter);
082:                if (index != -1) {
083:                    return new QuickAccessEntry(
084:                            this ,
085:                            providerForMatching,
086:                            new int[][] { { index, index + filter.length() - 1 } },
087:                            EMPTY_INDICES);
088:                }
089:                String combinedLabel = (providerForMatching.getName() + " " + getLabel()); //$NON-NLS-1$
090:                index = combinedLabel.toLowerCase().indexOf(filter);
091:                if (index != -1) {
092:                    int lengthOfElementMatch = index + filter.length()
093:                            - providerForMatching.getName().length() - 1;
094:                    if (lengthOfElementMatch > 0) {
095:                        return new QuickAccessEntry(
096:                                this ,
097:                                providerForMatching,
098:                                new int[][] { { 0, lengthOfElementMatch - 1 } },
099:                                new int[][] { { index,
100:                                        index + filter.length() - 1 } });
101:                    }
102:                    return new QuickAccessEntry(this , providerForMatching,
103:                            EMPTY_INDICES, new int[][] { { index,
104:                                    index + filter.length() - 1 } });
105:                }
106:                String camelCase = CamelUtil.getCamelCase(sortLabel);
107:                index = camelCase.indexOf(filter);
108:                if (index != -1) {
109:                    int[][] indices = CamelUtil.getCamelCaseIndices(sortLabel,
110:                            index, filter.length());
111:                    return new QuickAccessEntry(this , providerForMatching,
112:                            indices, EMPTY_INDICES);
113:                }
114:                String combinedCamelCase = CamelUtil
115:                        .getCamelCase(combinedLabel);
116:                index = combinedCamelCase.indexOf(filter);
117:                if (index != -1) {
118:                    String providerCamelCase = CamelUtil
119:                            .getCamelCase(providerForMatching.getName());
120:                    int lengthOfElementMatch = index + filter.length()
121:                            - providerCamelCase.length();
122:                    if (lengthOfElementMatch > 0) {
123:                        return new QuickAccessEntry(this , providerForMatching,
124:                                CamelUtil.getCamelCaseIndices(sortLabel, 0,
125:                                        lengthOfElementMatch), CamelUtil
126:                                        .getCamelCaseIndices(
127:                                                providerForMatching.getName(),
128:                                                index, filter.length()
129:                                                        - lengthOfElementMatch));
130:                    }
131:                    return new QuickAccessEntry(this, providerForMatching,
132:                            EMPTY_INDICES, CamelUtil.getCamelCaseIndices(
133:                                    providerForMatching.getName(), index,
134:                                    filter.length()));
135:                }
136:                return null;
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.