Source Code Cross Referenced for ConfigurationLogDefaultSection.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) 2003, 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.about;
011:
012:        import java.io.BufferedReader;
013:        import java.io.ByteArrayInputStream;
014:        import java.io.ByteArrayOutputStream;
015:        import java.io.IOException;
016:        import java.io.InputStreamReader;
017:        import java.io.PrintWriter;
018:        import java.util.Comparator;
019:        import java.util.Iterator;
020:        import java.util.LinkedList;
021:        import java.util.Properties;
022:        import java.util.SortedSet;
023:        import java.util.TreeSet;
024:
025:        import org.eclipse.core.runtime.CoreException;
026:        import org.eclipse.core.runtime.IBundleGroup;
027:        import org.eclipse.core.runtime.IBundleGroupProvider;
028:        import org.eclipse.core.runtime.Platform;
029:        import org.eclipse.core.runtime.preferences.IEclipsePreferences;
030:        import org.eclipse.core.runtime.preferences.IPreferencesService;
031:        import org.eclipse.osgi.util.NLS;
032:        import org.eclipse.ui.about.ISystemSummarySection;
033:        import org.eclipse.ui.internal.WorkbenchMessages;
034:        import org.eclipse.ui.internal.WorkbenchPlugin;
035:        import org.eclipse.ui.internal.util.Util;
036:        import org.osgi.framework.Bundle;
037:
038:        /**
039:         * This class puts basic platform information into the system summary log.  This
040:         * includes sections for the java properties, the ids of all installed features
041:         * and plugins, as well as a the current contents of the preferences service. 
042:         * 
043:         * @since 3.0
044:         */
045:        public class ConfigurationLogDefaultSection implements 
046:                ISystemSummarySection {
047:
048:            private static final String ECLIPSE_PROPERTY_PREFIX = "eclipse."; //$NON-NLS-1$
049:
050:            /* (non-Javadoc)
051:             * @see org.eclipse.ui.about.ISystemSummarySection#write(java.io.PrintWriter)
052:             */
053:            public void write(PrintWriter writer) {
054:                appendProperties(writer);
055:                appendFeatures(writer);
056:                appendRegistry(writer);
057:                appendUserPreferences(writer);
058:            }
059:
060:            /**
061:             * Appends the <code>System</code> properties.
062:             */
063:            private void appendProperties(PrintWriter writer) {
064:                writer.println();
065:                writer
066:                        .println(WorkbenchMessages.SystemSummary_systemProperties);
067:                Properties properties = System.getProperties();
068:                SortedSet set = new TreeSet(new Comparator() {
069:                    public int compare(Object o1, Object o2) {
070:                        String s1 = (String) o1;
071:                        String s2 = (String) o2;
072:                        return s1.compareTo(s2);
073:                    }
074:                });
075:                set.addAll(properties.keySet());
076:                Iterator i = set.iterator();
077:                while (i.hasNext()) {
078:                    String key = (String) i.next();
079:                    String value = properties.getProperty(key);
080:
081:                    writer.print(key);
082:                    writer.print('=');
083:
084:                    // some types of properties have special characters embedded
085:                    if (key.startsWith(ECLIPSE_PROPERTY_PREFIX)) {
086:                        printEclipseProperty(writer, value);
087:                    } else if (key.toUpperCase().indexOf("PASSWORD") != -1) { //$NON-NLS-1$
088:                        // We should obscure any property that may be a password
089:                        for (int j = 0; j < value.length(); j++) {
090:                            writer.print('*');
091:                        }
092:                        writer.println();
093:                    } else {
094:                        writer.println(value);
095:                    }
096:                }
097:            }
098:
099:            private static void printEclipseProperty(PrintWriter writer,
100:                    String value) {
101:                String[] lines = Util.getArrayFromList(value, "\n"); //$NON-NLS-1$
102:                for (int i = 0; i < lines.length; ++i) {
103:                    writer.println(lines[i]);
104:                }
105:            }
106:
107:            /**
108:             * Appends the installed and configured features.
109:             */
110:            private void appendFeatures(PrintWriter writer) {
111:                writer.println();
112:                writer.println(WorkbenchMessages.SystemSummary_features);
113:
114:                IBundleGroupProvider[] providers = Platform
115:                        .getBundleGroupProviders();
116:                LinkedList groups = new LinkedList();
117:                if (providers != null) {
118:                    for (int i = 0; i < providers.length; ++i) {
119:                        IBundleGroup[] bundleGroups = providers[i]
120:                                .getBundleGroups();
121:                        for (int j = 0; j < bundleGroups.length; ++j) {
122:                            groups
123:                                    .add(new AboutBundleGroupData(
124:                                            bundleGroups[j]));
125:                        }
126:                    }
127:                }
128:                AboutBundleGroupData[] bundleGroupInfos = (AboutBundleGroupData[]) groups
129:                        .toArray(new AboutBundleGroupData[0]);
130:
131:                AboutData.sortById(false, bundleGroupInfos);
132:
133:                for (int i = 0; i < bundleGroupInfos.length; ++i) {
134:                    AboutBundleGroupData info = bundleGroupInfos[i];
135:                    String[] args = new String[] { info.getId(),
136:                            info.getVersion(), info.getName() };
137:                    writer.println(NLS.bind(
138:                            WorkbenchMessages.SystemSummary_featureVersion,
139:                            args));
140:                }
141:            }
142:
143:            /**
144:             * Appends the contents of the Plugin Registry.
145:             */
146:            private void appendRegistry(PrintWriter writer) {
147:                writer.println();
148:                writer.println(WorkbenchMessages.SystemSummary_pluginRegistry);
149:
150:                Bundle[] bundles = WorkbenchPlugin.getDefault().getBundles();
151:                AboutBundleData[] bundleInfos = new AboutBundleData[bundles.length];
152:
153:                for (int i = 0; i < bundles.length; ++i) {
154:                    bundleInfos[i] = new AboutBundleData(bundles[i]);
155:                }
156:
157:                AboutData.sortById(false, bundleInfos);
158:
159:                for (int i = 0; i < bundleInfos.length; ++i) {
160:                    AboutBundleData info = bundleInfos[i];
161:                    String[] args = new String[] { info.getId(),
162:                            info.getVersion(), info.getName(),
163:                            info.getStateName() };
164:                    writer
165:                            .println(NLS
166:                                    .bind(
167:                                            WorkbenchMessages.SystemSummary_descriptorIdVersionState,
168:                                            args));
169:                }
170:            }
171:
172:            /**
173:             * Appends the preferences
174:             */
175:            private void appendUserPreferences(PrintWriter writer) {
176:                // write the prefs to a byte array
177:                IPreferencesService service = Platform.getPreferencesService();
178:                IEclipsePreferences node = service.getRootNode();
179:                ByteArrayOutputStream stm = new ByteArrayOutputStream();
180:                try {
181:                    service.exportPreferences(node, stm, null);
182:                } catch (CoreException e) {
183:                    writer.println("Error reading preferences " + e.toString());//$NON-NLS-1$		
184:                }
185:
186:                // copy the prefs from the byte array to the writer
187:                writer.println();
188:                writer.println(WorkbenchMessages.SystemSummary_userPreferences);
189:
190:                BufferedReader reader = null;
191:                try {
192:                    ByteArrayInputStream in = new ByteArrayInputStream(stm
193:                            .toByteArray());
194:                    reader = new BufferedReader(new InputStreamReader(in,
195:                            "8859_1")); //$NON-NLS-1$
196:                    char[] chars = new char[8192];
197:
198:                    while (true) {
199:                        int read = reader.read(chars);
200:                        if (read <= 0) {
201:                            break;
202:                        }
203:                        writer.write(chars, 0, read);
204:                    }
205:                } catch (IOException e) {
206:                    writer.println("Error reading preferences " + e.toString());//$NON-NLS-1$		
207:                }
208:
209:                // ByteArray streams don't need to be closed
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.