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


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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.internal.about;
011:
012:        import java.io.IOException;
013:        import java.net.URL;
014:        import com.ibm.icu.text.Collator;
015:        import java.util.Arrays;
016:        import java.util.Collections;
017:        import java.util.Comparator;
018:        import java.util.List;
019:        import java.util.Locale;
020:
021:        import org.eclipse.jface.resource.ImageDescriptor;
022:
023:        /**
024:         * An abstract parent that describes data that can be displayed in a table in one of
025:         * the about dialogs.
026:         * @since 3.0 
027:         */
028:        public abstract class AboutData {
029:            private String providerName;
030:
031:            private String name;
032:
033:            private String version;
034:
035:            private String id;
036:
037:            private String versionedId = null;
038:
039:            protected AboutData(String providerName, String name,
040:                    String version, String id) {
041:                this .providerName = providerName == null ? "" : providerName; //$NON-NLS-1$
042:                this .name = name == null ? "" : name; //$NON-NLS-1$
043:                this .version = version == null ? "" : version; //$NON-NLS-1$
044:                this .id = id == null ? "" : id; //$NON-NLS-1$
045:            }
046:
047:            public String getId() {
048:                return id;
049:            }
050:
051:            public String getName() {
052:                return name;
053:            }
054:
055:            public String getProviderName() {
056:                return providerName;
057:            }
058:
059:            public String getVersion() {
060:                return version;
061:            }
062:
063:            public String getVersionedId() {
064:                if (versionedId == null) {
065:                    versionedId = getId() + "_" + getVersion(); //$NON-NLS-1$
066:                }
067:                return versionedId;
068:            }
069:
070:            /**
071:             * Modify the argument array to reverse the sort order. 
072:             * @param infos
073:             */
074:            private static void reverse(AboutData[] infos) {
075:                List infoList = Arrays.asList(infos);
076:                Collections.reverse(infoList);
077:                for (int i = 0; i < infos.length; ++i) {
078:                    infos[i] = (AboutData) infoList.get(i);
079:                }
080:            }
081:
082:            /**
083:             * Modify the argument array to be sorted by provider. If the reverse
084:             * boolean is true, the array is assumed to already be sorted and the
085:             * direction of sort (ascending vs. descending) is reversed.  Entries
086:             * with the same name are sorted by name.
087:             * 
088:             * @param reverse
089:             *            if true then the order of the argument is reversed without
090:             *            examining the value of the fields
091:             * @param infos
092:             *            the data to be sorted
093:             */
094:            public static void sortByProvider(boolean reverse, AboutData[] infos) {
095:                if (reverse) {
096:                    reverse(infos);
097:                    return;
098:                }
099:
100:                Arrays.sort(infos, new Comparator() {
101:                    Collator collator = Collator.getInstance(Locale
102:                            .getDefault());
103:
104:                    public int compare(Object a, Object b) {
105:                        AboutData info1 = (AboutData) a;
106:                        AboutData info2 = (AboutData) b;
107:
108:                        String provider1 = info1.getProviderName();
109:                        String provider2 = info2.getProviderName();
110:
111:                        if (!provider1.equals(provider2)) {
112:                            return collator.compare(provider1, provider2);
113:                        }
114:
115:                        return collator.compare(info1.getName(), info2
116:                                .getName());
117:                    }
118:                });
119:            }
120:
121:            /**
122:             * Modify the argument array to be sorted by name. If the reverse
123:             * boolean is true, the array is assumed to already be sorted and the
124:             * direction of sort (ascending vs. descending) is reversed.
125:             * 
126:             * @param reverse
127:             *            if true then the order of the argument is reversed without
128:             *            examining the value of the fields
129:             * @param infos
130:             *            the data to be sorted
131:             */
132:            public static void sortByName(boolean reverse, AboutData[] infos) {
133:                if (reverse) {
134:                    reverse(infos);
135:                    return;
136:                }
137:
138:                Arrays.sort(infos, new Comparator() {
139:                    Collator collator = Collator.getInstance(Locale
140:                            .getDefault());
141:
142:                    public int compare(Object a, Object b) {
143:                        AboutData info1 = (AboutData) a;
144:                        AboutData info2 = (AboutData) b;
145:                        return collator.compare(info1.getName(), info2
146:                                .getName());
147:                    }
148:                });
149:            }
150:
151:            /**
152:             * Modify the argument array to be sorted by version. If the reverse
153:             * boolean is true, the array is assumed to already be sorted and the
154:             * direction of sort (ascending vs. descending) is reversed.  Entries
155:             * with the same name are sorted by name.
156:             * 
157:             * @param reverse
158:             *            if true then the order of the argument is reversed without
159:             *            examining the value of the fields
160:             * @param infos
161:             *            the data to be sorted
162:             */
163:            public static void sortByVersion(boolean reverse, AboutData[] infos) {
164:                if (reverse) {
165:                    reverse(infos);
166:                    return;
167:                }
168:
169:                Arrays.sort(infos, new Comparator() {
170:                    Collator collator = Collator.getInstance(Locale
171:                            .getDefault());
172:
173:                    public int compare(Object a, Object b) {
174:                        AboutData info1 = (AboutData) a;
175:                        AboutData info2 = (AboutData) b;
176:
177:                        String version1 = info1.getVersion();
178:                        String version2 = info2.getVersion();
179:
180:                        if (!version1.equals(version2)) {
181:                            return collator.compare(version1, version2);
182:                        }
183:
184:                        return collator.compare(info1.getName(), info2
185:                                .getName());
186:                    }
187:                });
188:            }
189:
190:            /**
191:             * Modify the argument array to be sorted by id. If the reverse
192:             * boolean is true, the array is assumed to already be sorted and the
193:             * direction of sort (ascending vs. descending) is reversed.  Entries
194:             * with the same name are sorted by name.
195:             * 
196:             * @param reverse
197:             *            if true then the order of the argument is reversed without
198:             *            examining the value of the fields
199:             * @param infos
200:             *            the data to be sorted
201:             */
202:            public static void sortById(boolean reverse, AboutData[] infos) {
203:                if (reverse) {
204:                    reverse(infos);
205:                    return;
206:                }
207:
208:                Arrays.sort(infos, new Comparator() {
209:                    Collator collator = Collator.getInstance(Locale
210:                            .getDefault());
211:
212:                    public int compare(Object a, Object b) {
213:                        AboutData info1 = (AboutData) a;
214:                        AboutData info2 = (AboutData) b;
215:
216:                        String id1 = info1.getId();
217:                        String id2 = info2.getId();
218:
219:                        if (!id1.equals(id2)) {
220:                            return collator.compare(id1, id2);
221:                        }
222:
223:                        return collator.compare(info1.getName(), info2
224:                                .getName());
225:                    }
226:                });
227:            }
228:
229:            protected static URL getURL(String value) {
230:                try {
231:                    if (value != null) {
232:                        return new URL(value);
233:                    }
234:                } catch (IOException e) {
235:                    // do nothing
236:                }
237:
238:                return null;
239:            }
240:
241:            protected static ImageDescriptor getImage(URL url) {
242:                return url == null ? null : ImageDescriptor.createFromURL(url);
243:            }
244:
245:            protected static ImageDescriptor getImage(String value) {
246:                return getImage(getURL(value));
247:            }
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.