Source Code Cross Referenced for StepsPanelComponent.java in  » IDE-Netbeans » profiler » org » netbeans » modules » profiler » attach » panels » components » 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 Netbeans » profiler » org.netbeans.modules.profiler.attach.panels.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         * The Original Software is NetBeans. The Initial Developer of the Original
026:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
027:         * Microsystems, Inc. All Rights Reserved.
028:         *
029:         * If you wish your version of this file to be governed by only the CDDL
030:         * or only the GPL Version 2, indicate your decision by adding
031:         * "[Contributor] elects to include this software in this distribution
032:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
033:         * single choice of license, a recipient has the option to distribute
034:         * your version of this file under either the CDDL, the GPL Version 2 or
035:         * to extend the choice of license to its licensees as provided above.
036:         * However, if you add GPL Version 2 code and therefore, elected the GPL
037:         * Version 2 license, then the option applies only if the new code is
038:         * made subject to such option by the copyright holder.
039:         */
040:
041:        package org.netbeans.modules.profiler.attach.panels.components;
042:
043:        import java.awt.Color;
044:        import java.text.MessageFormat;
045:        import java.util.Iterator;
046:        import java.util.List;
047:        import java.util.ResourceBundle;
048:        import javax.swing.UIManager;
049:        import org.netbeans.lib.profiler.ui.UIUtils;
050:        import org.netbeans.modules.profiler.attach.spi.IntegrationProvider;
051:
052:        /**
053:         *
054:         * @author  Jaroslav Bachorik
055:         */
056:        public class StepsPanelComponent extends javax.swing.JPanel {
057:            private final ResourceBundle messages = ResourceBundle
058:                    .getBundle("org/netbeans/modules/profiler/attach/panels/components/StepsPanelComponent"); // NOI18N
059:            private final String STEP = messages.getString("STEP"); // NOI18N
060:            private final String WARNINGS = messages.getString("WARNINGS"); // NOI18N
061:            private final String NOTES = messages.getString("NOTES"); // NOI18N
062:            private final String WARNING = messages.getString("WARNING"); //NOI18N
063:            private final String NOTE = messages.getString("NOTE"); // NOI18N
064:
065:            private final String EMPTY_HINT = "<html>\n  <head>\n    \n  </head>\n  <body>\n  </body>\n</html>\n"; // NOI18N
066:
067:            private final int LOCATION_TOP = 1;
068:            private final int LOCATION_MIDDLE = 2;
069:            private final int LOCATION_BOTTOM = 3;
070:
071:            private boolean warningsFirst = true;
072:            private boolean isLabelHidden = false;
073:
074:            private double lastLabelHeight = -1d;
075:
076:            /**
077:             * Creates new form StepsPanelComponent
078:             */
079:            public StepsPanelComponent() {
080:                initComponents();
081:            }
082:
083:            /** This method is called from within the constructor to
084:             * initialize the form.
085:             * WARNING: Do NOT modify this code. The content of this method is
086:             * always regenerated by the Form Editor.
087:             */
088:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
089:            private void initComponents() {
090:
091:                stepsScroller = new javax.swing.JScrollPane();
092:                areaSteps = new org.netbeans.lib.profiler.ui.components.HTMLTextArea();
093:                label = new javax.swing.JLabel();
094:                labelHints = new org.netbeans.lib.profiler.ui.components.HTMLLabel();
095:
096:                setMaximumSize(new java.awt.Dimension(800, 600));
097:                setMinimumSize(new java.awt.Dimension(400, 100));
098:                setPreferredSize(new java.awt.Dimension(400, 200));
099:                setRequestFocusEnabled(false);
100:                setLayout(new java.awt.BorderLayout());
101:
102:                stepsScroller.setMaximumSize(new java.awt.Dimension(800, 600));
103:                stepsScroller.setMinimumSize(new java.awt.Dimension(300, 100));
104:                stepsScroller
105:                        .setPreferredSize(new java.awt.Dimension(380, 100));
106:                stepsScroller.setViewportView(areaSteps);
107:
108:                add(stepsScroller, java.awt.BorderLayout.CENTER);
109:
110:                label.setLabelFor(areaSteps);
111:                org.openide.awt.Mnemonics.setLocalizedText(label,
112:                        org.openide.util.NbBundle.getMessage(
113:                                StepsPanelComponent.class,
114:                                "StepsPanelComponent.label.text")); // NOI18N
115:                label.setBorder(javax.swing.BorderFactory.createEmptyBorder(3,
116:                        3, 3, 3));
117:                add(label, java.awt.BorderLayout.NORTH);
118:
119:                labelHints.setBorder(javax.swing.BorderFactory
120:                        .createEmptyBorder(3, 3, 3, 3));
121:                labelHints.setText(org.openide.util.NbBundle.getMessage(
122:                        StepsPanelComponent.class,
123:                        "StepsPanelComponent.labelHints.text")); // NOI18N
124:                labelHints.setMaximumSize(new java.awt.Dimension(300, 100));
125:                labelHints.setMinimumSize(new java.awt.Dimension(300, 0));
126:                labelHints.setPreferredSize(new java.awt.Dimension(300, 60));
127:                Color panelBackground = UIManager.getColor("Panel.background"); // NOI18N;
128:                Color hintBackground = UIUtils.getSafeColor(panelBackground
129:                        .getRed() - 10, panelBackground.getGreen() - 10,
130:                        panelBackground.getBlue() - 10);
131:                labelHints.setDisabledTextColor(Color.darkGray);
132:                labelHints.setBackground(hintBackground);
133:                add(labelHints, java.awt.BorderLayout.SOUTH);
134:                labelHints
135:                        .getAccessibleContext()
136:                        .setAccessibleName(
137:                                org.openide.util.NbBundle
138:                                        .getMessage(StepsPanelComponent.class,
139:                                                "StepsPanelComponent.labelHints.AccessibleContext.accessibleName")); // NOI18N
140:            }// </editor-fold>//GEN-END:initComponents
141:
142:            // Variables declaration - do not modify//GEN-BEGIN:variables
143:            private org.netbeans.lib.profiler.ui.components.HTMLTextArea areaSteps;
144:            private javax.swing.JLabel label;
145:            private org.netbeans.lib.profiler.ui.components.HTMLLabel labelHints;
146:            private javax.swing.JScrollPane stepsScroller;
147:
148:            // End of variables declaration//GEN-END:variables
149:
150:            /**
151:             * Getter for property title.
152:             * @return Value of property title.
153:             */
154:            public String getTitle() {
155:                return label.getText();
156:            }
157:
158:            /**
159:             * Setter for property title.
160:             * @param title New value of property title.
161:             */
162:            public void setTitle(String title) {
163:                org.openide.awt.Mnemonics.setLocalizedText(label, title);
164:            }
165:
166:            /**
167:             * Holds value of property steps.
168:             */
169:            private IntegrationProvider.IntegrationHints steps;
170:
171:            /**
172:             * Getter for property steps.
173:             * @return Value of property steps.
174:             */
175:            public IntegrationProvider.IntegrationHints getSteps() {
176:                return this .steps;
177:            }
178:
179:            /**
180:             * Setter for property steps.
181:             * @param steps New value of property steps.
182:             */
183:            public void setSteps(IntegrationProvider.IntegrationHints steps) {
184:                this .steps = steps;
185:
186:                if (steps == null) {
187:                    areaSteps.setText(""); // NOI18N
188:                    return;
189:                }
190:
191:                StringBuffer hintText = new StringBuffer();
192:                if (steps.isWarningsFirst()) {
193:                    appendWarnings(hintText);
194:                }
195:                appendSteps(hintText);
196:                if (!steps.isWarningsFirst()) {
197:                    appendWarnings(hintText);
198:                }
199:                appendHints(hintText);
200:
201:                hintText.append("<br>"); // NOI18N
202:
203:                areaSteps.setText(hintText.toString());
204:                areaSteps.setCaretPosition(0); // scroll to the top of the text
205:            }
206:
207:            private void appendHints(final StringBuffer hintText) {
208:                if (this .steps.getHints().size() > 0) {
209:                    exportAsHtmlList(this .steps.getHints(), NOTE, true,
210:                            hintText);
211:                }
212:            }
213:
214:            private void appendWarnings(final StringBuffer hintText) {
215:                final boolean isLast = !steps.isWarningsFirst()
216:                        && steps.getHints().size() == 0;
217:                if (this .steps.getWarnings().size() > 0) {
218:                    exportAsHtmlList(this .steps.getWarnings(), WARNING,
219:                            "#594FBF", isLast, hintText); // NOI18N
220:                }
221:            }
222:
223:            private void appendSteps(final StringBuffer buffer) {
224:                final boolean isLast = (steps.isWarningsFirst() && steps
225:                        .getHints().size() == 0)
226:                        || (steps.getHints().size() == 0 && steps.getWarnings()
227:                                .size() == 0);
228:                exportAsHtmlList(this .steps.getSteps(), STEP, isLast, buffer);
229:            }
230:
231:            private void exportAsHtmlList(final List listToExport,
232:                    final String prefix, final boolean isLast,
233:                    StringBuffer buffer) {
234:                exportAsHtmlList(listToExport, prefix, null, isLast, buffer);
235:            }
236:
237:            private void exportAsHtmlList(final List listToExport,
238:                    final String prefix, final String color,
239:                    final boolean isLast, StringBuffer buffer) {
240:                int stepCounter = 1;
241:                for (Iterator it = listToExport.iterator(); it.hasNext();) {
242:                    buffer.append("<p>").append("<b>").append(
243:                            MessageFormat
244:                                    .format(prefix, new Object[] { new Integer(
245:                                            stepCounter++) })).append("</b>")
246:                            .append(" "); // NOI18N
247:                    StringBuffer innerMessage = new StringBuffer();
248:                    innerMessage.append(it.next()).append("</p>"); // NOI18N
249:                    if (color != null) {
250:                        buffer.append("<span style='color:").append(color)
251:                                .append("'>").append(innerMessage).append(
252:                                        "</span>"); // NOI18N
253:                    } else {
254:                        buffer.append(innerMessage);
255:                    }
256:                }
257:                if (!isLast) {
258:                    buffer.append("<br><hr>"); // NOI18N
259:                }
260:            }
261:
262:            /**
263:             * Getter for property hintText.
264:             * @return Value of property hintText.
265:             */
266:            public String getHintText() {
267:                return labelHints.getText();
268:            }
269:
270:            /**
271:             * Setter for property hintText.
272:             * @param hintText New value of property hintText.
273:             */
274:            public void setHintText(String hintText) {
275:                labelHints.setText(hintText);
276:                if (hintText == null || hintText.length() == 0
277:                        || labelHints.getText().equals(EMPTY_HINT)) {
278:                    labelHints.setVisible(false);
279:                } else {
280:                    labelHints.setVisible(true);
281:                }
282:                revalidate();
283:            }
284:        }
w___ww_.___ja___v__a__2_s_._com__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.