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


001:        /*******************************************************************************
002:         * Copyright (c) 2004, 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.part;
011:
012:        import java.io.PrintWriter;
013:        import java.io.StringWriter;
014:
015:        import org.eclipse.core.runtime.IStatus;
016:        import org.eclipse.jface.dialogs.IDialogConstants;
017:        import org.eclipse.swt.SWT;
018:        import org.eclipse.swt.events.SelectionAdapter;
019:        import org.eclipse.swt.events.SelectionEvent;
020:        import org.eclipse.swt.graphics.Image;
021:        import org.eclipse.swt.layout.FillLayout;
022:        import org.eclipse.swt.layout.GridData;
023:        import org.eclipse.swt.layout.GridLayout;
024:        import org.eclipse.swt.widgets.Button;
025:        import org.eclipse.swt.widgets.Composite;
026:        import org.eclipse.swt.widgets.Control;
027:        import org.eclipse.swt.widgets.Display;
028:        import org.eclipse.swt.widgets.Label;
029:        import org.eclipse.swt.widgets.Text;
030:
031:        /**
032:         * @since 3.1
033:         */
034:        public class StatusPart {
035:
036:            boolean showingDetails = false;
037:            private Button detailsButton;
038:            private Composite detailsArea;
039:            private Control details = null;
040:            private IStatus reason;
041:
042:            public StatusPart(final Composite parent, IStatus reason_) {
043:                this .reason = reason_;
044:                GridLayout layout = new GridLayout();
045:
046:                layout.numColumns = 3;
047:
048:                int spacing = 8;
049:                int margins = 8;
050:                layout.marginBottom = margins;
051:                layout.marginTop = margins;
052:                layout.marginLeft = margins;
053:                layout.marginRight = margins;
054:                layout.horizontalSpacing = spacing;
055:                layout.verticalSpacing = spacing;
056:                parent.setLayout(layout);
057:
058:                Label imageLabel = new Label(parent, SWT.NONE);
059:                Image image = getImage();
060:                if (image != null) {
061:                    image.setBackground(imageLabel.getBackground());
062:                    imageLabel.setImage(image);
063:                    imageLabel.setLayoutData(new GridData(
064:                            GridData.HORIZONTAL_ALIGN_CENTER
065:                                    | GridData.VERTICAL_ALIGN_BEGINNING));
066:                }
067:
068:                Text text = new Text(parent, SWT.MULTI | SWT.READ_ONLY
069:                        | SWT.WRAP);
070:                text.setBackground(text.getDisplay().getSystemColor(
071:                        SWT.COLOR_WIDGET_BACKGROUND));
072:
073:                //text.setForeground(JFaceColors.getErrorText(text.getDisplay()));
074:                text.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL
075:                        | GridData.GRAB_HORIZONTAL
076:                        | GridData.VERTICAL_ALIGN_BEGINNING));
077:                text.setText(reason.getMessage());
078:
079:                detailsButton = new Button(parent, SWT.PUSH);
080:                detailsButton.addSelectionListener(new SelectionAdapter() {
081:                    public void widgetSelected(SelectionEvent e) {
082:                        showDetails(!showingDetails);
083:                    }
084:                });
085:
086:                detailsButton.setLayoutData(new GridData(
087:                        GridData.HORIZONTAL_ALIGN_BEGINNING
088:                                | GridData.VERTICAL_ALIGN_BEGINNING));
089:                detailsButton.setVisible(reason.getException() != null);
090:
091:                updateDetailsText();
092:
093:                detailsArea = new Composite(parent, SWT.NONE);
094:                GridData data = new GridData(GridData.FILL_BOTH);
095:                data.horizontalSpan = 3;
096:                data.verticalSpan = 1;
097:                detailsArea.setLayoutData(data);
098:                detailsArea.setLayout(new FillLayout());
099:                parent.layout(true);
100:            }
101:
102:            /**
103:             * Return the image for the upper-left corner of this part
104:             *
105:             * @return
106:             */
107:            private Image getImage() {
108:                Display d = Display.getCurrent();
109:
110:                switch (reason.getSeverity()) {
111:                case IStatus.ERROR:
112:                    return d.getSystemImage(SWT.ICON_ERROR);
113:                case IStatus.WARNING:
114:                    return d.getSystemImage(SWT.ICON_WARNING);
115:                default:
116:                    return d.getSystemImage(SWT.ICON_INFORMATION);
117:                }
118:            }
119:
120:            private void showDetails(boolean shouldShow) {
121:                if (shouldShow == showingDetails) {
122:                    return;
123:                }
124:                this .showingDetails = shouldShow;
125:                updateDetailsText();
126:            }
127:
128:            private void updateDetailsText() {
129:                if (details != null) {
130:                    details.dispose();
131:                    details = null;
132:                }
133:
134:                if (showingDetails) {
135:                    detailsButton.setText(IDialogConstants.HIDE_DETAILS_LABEL);
136:                    Text detailsText = new Text(detailsArea, SWT.BORDER
137:                            | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI
138:                            | SWT.READ_ONLY | SWT.LEFT_TO_RIGHT);
139:                    detailsText.setText(getDetails(reason));
140:                    detailsText.setBackground(detailsText.getDisplay()
141:                            .getSystemColor(SWT.COLOR_LIST_BACKGROUND));
142:                    details = detailsText;
143:                    detailsArea.layout(true);
144:                } else {
145:                    detailsButton.setText(IDialogConstants.SHOW_DETAILS_LABEL);
146:                }
147:            }
148:
149:            private String getDetails(IStatus status) {
150:                if (status.getException() != null) {
151:                    return getStackTrace(status.getException());
152:                }
153:
154:                return ""; //$NON-NLS-1$
155:            }
156:
157:            private String getStackTrace(Throwable throwable) {
158:                StringWriter swriter = new StringWriter();
159:                PrintWriter pwriter = new PrintWriter(swriter);
160:                throwable.printStackTrace(pwriter);
161:                pwriter.flush();
162:                pwriter.close();
163:                return swriter.toString();
164:            }
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.