Source Code Cross Referenced for OperationPanel.java in  » IDE-Netbeans » autoupdate » org » netbeans » modules » autoupdate » ui » wizards » 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 » autoupdate » org.netbeans.modules.autoupdate.ui.wizards 
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-2008 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:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.autoupdate.ui.wizards;
043:
044:        import java.awt.BorderLayout;
045:        import java.awt.Dimension;
046:        import java.util.ArrayList;
047:        import java.util.List;
048:        import java.util.Set;
049:        import javax.swing.JComponent;
050:        import javax.swing.JLabel;
051:        import javax.swing.JTextArea;
052:        import javax.swing.JTextPane;
053:        import javax.swing.SwingUtilities;
054:        import org.netbeans.api.autoupdate.UpdateElement;
055:        import org.openide.util.RequestProcessor;
056:
057:        /**
058:         *
059:         * @author  Jiri Rechtacek
060:         */
061:        public class OperationPanel extends javax.swing.JPanel {
062:
063:            static final String RUN_ACTION = "run-action";
064:            static final String RUN_IN_BACKGROUND = "run-in-background";
065:
066:            public OperationPanel(boolean allowRunInBackground) {
067:                initComponents();
068:                rbRestartNow.setSelected(true);
069:                cbRunInBackground.setVisible(allowRunInBackground);
070:                if (allowRunInBackground) {
071:                    cbRunInBackground.setSelected(false);
072:                }
073:                setRestartButtonsVisible(false);
074:            }
075:
076:            @Override
077:            public void addNotify() {
078:                super .addNotify();
079:                RequestProcessor.getDefault().post(new Runnable() {
080:                    public void run() {
081:                        firePropertyChange(RUN_ACTION, null, Boolean.TRUE);
082:                    }
083:                }, 200);
084:            }
085:
086:            public void waitAndSetProgressComponents(final JLabel mainLabel,
087:                    final JComponent progressComponent, final JLabel detailLabel) {
088:                if (SwingUtilities.isEventDispatchThread()) {
089:                    setProgressComponents(mainLabel, progressComponent,
090:                            detailLabel);
091:                } else {
092:                    SwingUtilities.invokeLater(new Runnable() {
093:                        public void run() {
094:                            setProgressComponents(mainLabel, progressComponent,
095:                                    detailLabel);
096:                        }
097:                    });
098:                }
099:            }
100:
101:            public void setRestartButtonsVisible(final boolean visible) {
102:                if (SwingUtilities.isEventDispatchThread()) {
103:                    rbRestartLater.setVisible(visible);
104:                    rbRestartNow.setVisible(visible);
105:                } else {
106:                    SwingUtilities.invokeLater(new Runnable() {
107:                        public void run() {
108:                            rbRestartLater.setVisible(visible);
109:                            rbRestartNow.setVisible(visible);
110:                        }
111:                    });
112:                }
113:            }
114:
115:            public boolean restartNow() {
116:                return rbRestartNow.isSelected();
117:            }
118:
119:            public void hideRunInBackground() {
120:                if (SwingUtilities.isEventDispatchThread()) {
121:                    cbRunInBackground.setVisible(false);
122:                } else {
123:                    SwingUtilities.invokeLater(new Runnable() {
124:                        public void run() {
125:                            cbRunInBackground.setVisible(false);
126:                        }
127:                    });
128:                }
129:            }
130:
131:            private void setProgressComponents(JLabel mainLabel,
132:                    JComponent progressComponent, JLabel detailLabel) {
133:                assert pProgress != null;
134:                assert SwingUtilities.isEventDispatchThread() : "Must be called in EQ.";
135:                mainLabel.setPreferredSize(new Dimension(0, 20));
136:                detailLabel.setPreferredSize(new Dimension(0, 20));
137:                progressComponent.setPreferredSize(new Dimension(0, 20));
138:                pProgress.removeAll();
139:                pProgress.add(mainLabel, BorderLayout.NORTH);
140:                pProgress.add(progressComponent, BorderLayout.CENTER);
141:                pProgress.add(detailLabel, BorderLayout.SOUTH);
142:                revalidate();
143:            }
144:
145:            public void setBody(final String msg, final String text) {
146:                if (SwingUtilities.isEventDispatchThread()) {
147:                    setBodyInEQ(msg, text);
148:                } else {
149:                    SwingUtilities.invokeLater(new Runnable() {
150:                        public void run() {
151:                            setBodyInEQ(msg, text);
152:                        }
153:                    });
154:                }
155:            }
156:
157:            public void setBody(final String msg,
158:                    final Set<UpdateElement> updateElements) {
159:                final List<UpdateElement> elements = new ArrayList<UpdateElement>(
160:                        updateElements);
161:                if (SwingUtilities.isEventDispatchThread()) {
162:                    setBodyInEQ(msg, elements);
163:                } else {
164:                    SwingUtilities.invokeLater(new Runnable() {
165:                        public void run() {
166:                            setBodyInEQ(msg, elements);
167:                        }
168:                    });
169:                }
170:            }
171:
172:            private void setBodyInEQ(String msg, List<UpdateElement> elements) {
173:                pProgress.removeAll();
174:                pProgress.add(getTitleComponent(msg), BorderLayout.NORTH);
175:                pProgress.add(getElementsComponent(elements),
176:                        BorderLayout.CENTER);
177:                revalidate();
178:            }
179:
180:            private void setBodyInEQ(String msg, String elements) {
181:                pProgress.removeAll();
182:                pProgress.add(getTitleComponent(msg), BorderLayout.NORTH);
183:                pProgress.add(getElementsComponent(elements),
184:                        BorderLayout.CENTER);
185:                revalidate();
186:            }
187:
188:            private JComponent getTitleComponent(String msg) {
189:                JTextArea area = new JTextArea(msg);
190:                area.setWrapStyleWord(true);
191:                area.setLineWrap(true);
192:                area.setEditable(false);
193:                area.setOpaque(false);
194:                return area;
195:            }
196:
197:            private JComponent getElementsComponent(List<UpdateElement> elements) {
198:                JTextPane area = new JTextPane();
199:                area.setEditable(false);
200:                area.setContentType("text/html"); // NOI18N
201:                String body = new String();
202:                for (UpdateElement el : elements) {
203:                    body = body + el.getDisplayName() + "<br>"; // NOI18N
204:                }
205:                area.setText(body);
206:                area.setOpaque(false);
207:                return area;
208:            }
209:
210:            private JComponent getElementsComponent(String msg) {
211:                JTextPane area = new JTextPane();
212:                area.setEditable(false);
213:                area.setContentType("text/html"); // NOI18N
214:                area.setText(msg);
215:                area.setOpaque(false);
216:                return area;
217:            }
218:
219:            /** This method is called from within the constructor to
220:             * initialize the form.
221:             * WARNING: Do NOT modify this code. The content of this method is
222:             * always regenerated by the Form Editor.
223:             */
224:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
225:            private void initComponents() {
226:
227:                bgRestartButtons = new javax.swing.ButtonGroup();
228:                pAboveSpace = new javax.swing.JPanel();
229:                pProgress = new javax.swing.JPanel();
230:                pbPlaceHolder = new javax.swing.JProgressBar();
231:                lMainLabel = new javax.swing.JLabel();
232:                lDetailLabel = new javax.swing.JLabel();
233:                rbRestartNow = new javax.swing.JRadioButton();
234:                rbRestartLater = new javax.swing.JRadioButton();
235:                cbRunInBackground = new javax.swing.JCheckBox();
236:
237:                pAboveSpace.setOpaque(false);
238:
239:                org.jdesktop.layout.GroupLayout pAboveSpaceLayout = new org.jdesktop.layout.GroupLayout(
240:                        pAboveSpace);
241:                pAboveSpace.setLayout(pAboveSpaceLayout);
242:                pAboveSpaceLayout.setHorizontalGroup(pAboveSpaceLayout
243:                        .createParallelGroup(
244:                                org.jdesktop.layout.GroupLayout.LEADING).add(0,
245:                                148, Short.MAX_VALUE));
246:                pAboveSpaceLayout.setVerticalGroup(pAboveSpaceLayout
247:                        .createParallelGroup(
248:                                org.jdesktop.layout.GroupLayout.LEADING).add(0,
249:                                65, Short.MAX_VALUE));
250:
251:                pProgress.setLayout(new java.awt.BorderLayout());
252:
253:                pbPlaceHolder.setPreferredSize(new java.awt.Dimension(0, 20));
254:                pProgress.add(pbPlaceHolder, java.awt.BorderLayout.CENTER);
255:                pProgress.add(lMainLabel, java.awt.BorderLayout.NORTH);
256:                pProgress.add(lDetailLabel, java.awt.BorderLayout.SOUTH);
257:
258:                bgRestartButtons.add(rbRestartNow);
259:                org.openide.awt.Mnemonics.setLocalizedText(rbRestartNow,
260:                        org.openide.util.NbBundle.getMessage(
261:                                OperationPanel.class,
262:                                "InstallUnitWizardModel_Buttons_RestartNow")); // NOI18N
263:                rbRestartNow.setBorder(javax.swing.BorderFactory
264:                        .createEmptyBorder(0, 0, 0, 0));
265:                rbRestartNow
266:                        .addActionListener(new java.awt.event.ActionListener() {
267:                            public void actionPerformed(
268:                                    java.awt.event.ActionEvent evt) {
269:                                rbRestartNowActionPerformed(evt);
270:                            }
271:                        });
272:
273:                bgRestartButtons.add(rbRestartLater);
274:                org.openide.awt.Mnemonics.setLocalizedText(rbRestartLater,
275:                        org.openide.util.NbBundle.getMessage(
276:                                OperationPanel.class,
277:                                "InstallUnitWizardModel_Buttons_RestartLater")); // NOI18N
278:                rbRestartLater.setBorder(javax.swing.BorderFactory
279:                        .createEmptyBorder(0, 0, 0, 0));
280:                rbRestartLater
281:                        .addActionListener(new java.awt.event.ActionListener() {
282:                            public void actionPerformed(
283:                                    java.awt.event.ActionEvent evt) {
284:                                rbRestartLaterActionPerformed(evt);
285:                            }
286:                        });
287:
288:                org.openide.awt.Mnemonics.setLocalizedText(cbRunInBackground,
289:                        org.openide.util.NbBundle.getMessage(
290:                                OperationPanel.class,
291:                                "OperationPanel.cbRunInBackground.text")); // NOI18N
292:                cbRunInBackground
293:                        .addActionListener(new java.awt.event.ActionListener() {
294:                            public void actionPerformed(
295:                                    java.awt.event.ActionEvent evt) {
296:                                cbRunInBackgroundActionPerformed(evt);
297:                            }
298:                        });
299:
300:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
301:                        this );
302:                this .setLayout(layout);
303:                layout
304:                        .setHorizontalGroup(layout
305:                                .createParallelGroup(
306:                                        org.jdesktop.layout.GroupLayout.LEADING)
307:                                .add(
308:                                        layout
309:                                                .createSequentialGroup()
310:                                                .addContainerGap()
311:                                                .add(
312:                                                        layout
313:                                                                .createParallelGroup(
314:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
315:                                                                .add(
316:                                                                        pProgress,
317:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
318:                                                                        148,
319:                                                                        Short.MAX_VALUE)
320:                                                                .add(
321:                                                                        pAboveSpace,
322:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
323:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
324:                                                                        Short.MAX_VALUE)
325:                                                                .add(
326:                                                                        rbRestartNow)
327:                                                                .add(
328:                                                                        rbRestartLater)
329:                                                                .add(
330:                                                                        cbRunInBackground))
331:                                                .addContainerGap()));
332:                layout
333:                        .setVerticalGroup(layout
334:                                .createParallelGroup(
335:                                        org.jdesktop.layout.GroupLayout.LEADING)
336:                                .add(
337:                                        layout
338:                                                .createSequentialGroup()
339:                                                .addContainerGap()
340:                                                .add(
341:                                                        pAboveSpace,
342:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
343:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
344:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
345:                                                .addPreferredGap(
346:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
347:                                                .add(
348:                                                        pProgress,
349:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
350:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
351:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
352:                                                .addPreferredGap(
353:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
354:                                                .add(cbRunInBackground)
355:                                                .addPreferredGap(
356:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
357:                                                .add(rbRestartNow)
358:                                                .addPreferredGap(
359:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
360:                                                .add(rbRestartLater)
361:                                                .addContainerGap(45,
362:                                                        Short.MAX_VALUE)));
363:            }// </editor-fold>//GEN-END:initComponents
364:
365:            private void rbRestartLaterActionPerformed(
366:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbRestartLaterActionPerformed
367:                // TODO add your handling code here:
368:            }//GEN-LAST:event_rbRestartLaterActionPerformed
369:
370:            private void rbRestartNowActionPerformed(
371:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rbRestartNowActionPerformed
372:                // TODO add your handling code here:
373:            }//GEN-LAST:event_rbRestartNowActionPerformed
374:
375:            private void cbRunInBackgroundActionPerformed(
376:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbRunInBackgroundActionPerformed
377:                firePropertyChange(RUN_IN_BACKGROUND, null, Boolean.TRUE);
378:            }//GEN-LAST:event_cbRunInBackgroundActionPerformed
379:
380:            // Variables declaration - do not modify//GEN-BEGIN:variables
381:            private javax.swing.ButtonGroup bgRestartButtons;
382:            private javax.swing.JCheckBox cbRunInBackground;
383:            private javax.swing.JLabel lDetailLabel;
384:            private javax.swing.JLabel lMainLabel;
385:            private javax.swing.JPanel pAboveSpace;
386:            private javax.swing.JPanel pProgress;
387:            private javax.swing.JProgressBar pbPlaceHolder;
388:            private javax.swing.JRadioButton rbRestartLater;
389:            private javax.swing.JRadioButton rbRestartNow;
390:            // End of variables declaration//GEN-END:variables
391:
392:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.