Source Code Cross Referenced for SwingFrameContainer.java in  » IDE-Netbeans » nbi » org » netbeans » installer » wizard » containers » 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 » nbi » org.netbeans.installer.wizard.containers 
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 General
007:         * Public License Version 2 only ("GPL") or the Common Development and Distribution
008:         * License("CDDL") (collectively, the "License"). You may not use this file except in
009:         * compliance with the License. You can obtain a copy of the License at
010:         * http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
011:         * License for the specific language governing permissions and limitations under the
012:         * License.  When distributing the software, include this License Header Notice in
013:         * each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP.  Sun
014:         * designates this particular file as subject to the "Classpath" exception as
015:         * provided by Sun in the GPL Version 2 section of the License file that
016:         * accompanied this code. If applicable, add the following below the License Header,
017:         * with the fields enclosed by brackets [] replaced by your own identifying
018:         * information: "Portions Copyrighted [year] [name of copyright owner]"
019:         *
020:         * Contributor(s):
021:         *
022:         * The Original Software is NetBeans. The Initial Developer of the Original Software
023:         * is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
024:         * Rights Reserved.
025:         *
026:         * If you wish your version of this file to be governed by only the CDDL or only the
027:         * GPL Version 2, indicate your decision by adding "[Contributor] elects to include
028:         * this software in this distribution under the [CDDL or GPL Version 2] license." If
029:         * you do not indicate a single choice of license, a recipient has the option to
030:         * distribute your version of this file under either the CDDL, the GPL Version 2 or
031:         * to extend the choice of license to its licensees as provided above. However, if
032:         * you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then
033:         * the option applies only if the new code is made subject to such option by the
034:         * copyright holder.
035:         */
036:
037:        package org.netbeans.installer.wizard.containers;
038:
039:        import java.awt.BorderLayout;
040:        import java.awt.Color;
041:        import java.awt.Dimension;
042:        import java.awt.Font;
043:        import java.awt.GridBagConstraints;
044:        import java.awt.GridBagLayout;
045:        import java.awt.Insets;
046:        import java.awt.event.ActionEvent;
047:        import java.awt.event.ActionListener;
048:        import java.awt.event.KeyEvent;
049:        import java.awt.event.WindowAdapter;
050:        import java.awt.event.WindowEvent;
051:        import java.net.MalformedURLException;
052:        import javax.swing.AbstractAction;
053:        import javax.swing.ImageIcon;
054:        import javax.swing.JRootPane;
055:        import javax.swing.KeyStroke;
056:        import javax.swing.SwingUtilities;
057:        import org.netbeans.installer.utils.ErrorManager;
058:        import org.netbeans.installer.utils.FileProxy;
059:        import org.netbeans.installer.utils.ResourceUtils;
060:        import org.netbeans.installer.utils.StringUtils;
061:        import org.netbeans.installer.utils.SystemUtils;
062:        import org.netbeans.installer.utils.UiUtils;
063:        import org.netbeans.installer.utils.exceptions.DownloadException;
064:        import org.netbeans.installer.utils.helper.swing.NbiButton;
065:        import org.netbeans.installer.utils.helper.swing.NbiFrame;
066:        import org.netbeans.installer.utils.helper.swing.NbiLabel;
067:        import org.netbeans.installer.utils.helper.swing.NbiPanel;
068:        import org.netbeans.installer.utils.helper.swing.NbiSeparator;
069:        import org.netbeans.installer.utils.helper.swing.NbiTextPane;
070:        import org.netbeans.installer.wizard.ui.SwingUi;
071:        import org.netbeans.installer.wizard.ui.WizardUi;
072:
073:        /**
074:         * This class is a conscrete implementation of the {@link SwingContainer} interface.
075:         * In this case the container is an {@link NbiFrame}.
076:         *
077:         * @author Kirill Sorokin
078:         * @sicne 1.0
079:         */
080:        public class SwingFrameContainer extends NbiFrame implements 
081:                SwingContainer {
082:            /////////////////////////////////////////////////////////////////////////////////
083:            // Instance
084:            /**
085:             * Instance of {@link SwingUi} that is currently shown by the container.
086:             */
087:            private SwingUi currentUi;
088:
089:            /**
090:             * Content pane used by the container.
091:             */
092:            private WizardFrameContentPane contentPane;
093:
094:            /**
095:             * Prefix of the container frame title.
096:             */
097:            private String frameTitlePrefix;
098:
099:            /**
100:             * Pattern which should be used to combine the container frame's title prefix
101:             * and the title of the current UI.
102:             */
103:            private String frameTitlePattern;
104:
105:            /**
106:             * Creates a new instance of {@link SwingFrameContainer}. The constructor calls
107:             * the initialization routine of the parent class and searches the system
108:             * properties for settings which may be releavant to this type of container.
109:             * Additionally it initializes and lays out the core swing components of the
110:             * container.
111:             */
112:            public SwingFrameContainer() {
113:                super ();
114:
115:                frameWidth = UiUtils
116:                        .getDimension(System.getProperties(),
117:                                WIZARD_FRAME_WIDTH_PROPERTY,
118:                                DEFAULT_WIZARD_FRAME_WIDTH);
119:                frameMinimumWidth = UiUtils.getDimension(
120:                        System.getProperties(),
121:                        WIZARD_FRAME_MINIMUM_WIDTH_PROPERTY,
122:                        DEFAULT_WIZARD_FRAME_MINIMUM_WIDTH);
123:                frameMaximumWidth = UiUtils.getDimension(
124:                        System.getProperties(),
125:                        WIZARD_FRAME_MAXIMUM_WIDTH_PROPERTY,
126:                        DEFAULT_WIZARD_FRAME_MAXIMUM_WIDTH);
127:
128:                frameHeight = UiUtils.getDimension(System.getProperties(),
129:                        WIZARD_FRAME_HEIGHT_PROPERTY,
130:                        DEFAULT_WIZARD_FRAME_HEIGHT);
131:                frameMinimumHeight = UiUtils.getDimension(System
132:                        .getProperties(), WIZARD_FRAME_MINIMUM_HEIGHT_PROPERTY,
133:                        DEFAULT_WIZARD_FRAME_MINIMUM_HEIGHT);
134:                frameMaximumHeight = UiUtils.getDimension(System
135:                        .getProperties(), WIZARD_FRAME_MAXIMUM_HEIGHT_PROPERTY,
136:                        DEFAULT_WIZARD_FRAME_MAXIMUM_HEIGHT);
137:
138:                boolean customIconLoaded = false;
139:                if (System.getProperty(WIZARD_FRAME_ICON_URI_PROPERTY) != null) {
140:                    final String frameIconUri = System
141:                            .getProperty(WIZARD_FRAME_ICON_URI_PROPERTY);
142:
143:                    try {
144:                        frameIcon = FileProxy.getInstance().getFile(
145:                                frameIconUri, true);
146:                        customIconLoaded = true;
147:                    } catch (DownloadException e) {
148:                        ErrorManager.notifyWarning(ResourceUtils.getString(
149:                                SwingFrameContainer.class,
150:                                RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON,
151:                                frameIconUri), e);
152:                    }
153:                }
154:
155:                if (!customIconLoaded) {
156:                    final String frameIconUri = DEFAULT_WIZARD_FRAME_ICON_URI;
157:
158:                    try {
159:                        frameIcon = FileProxy.getInstance().getFile(
160:                                frameIconUri, true);
161:                        customIconLoaded = true;
162:                    } catch (DownloadException e) {
163:                        ErrorManager.notifyWarning(ResourceUtils.getString(
164:                                SwingFrameContainer.class,
165:                                RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON,
166:                                frameIconUri), e);
167:                    }
168:                }
169:
170:                frameTitlePrefix = DEFAULT_WIZARD_FRAME_TITLE_PREFIX;
171:                if (System.getProperty(WIZARD_FRAME_TITLE_PREFIX_PROPERTY) != null) {
172:                    frameTitlePrefix = System
173:                            .getProperty(WIZARD_FRAME_TITLE_PREFIX_PROPERTY);
174:                }
175:
176:                frameTitlePattern = DEFAULT_WIZARD_FRAME_TITLE_PATTERN;
177:                if (System.getProperty(WIZARD_FRAME_TITLE_PATTERN_PROPERTY) != null) {
178:                    frameTitlePattern = System
179:                            .getProperty(WIZARD_FRAME_TITLE_PATTERN_PROPERTY);
180:                }
181:
182:                initComponents();
183:            }
184:
185:            /**
186:             * This method overrides {@link NbiFrame#setVisible()} and at the same time
187:             * implements {@link WizardContainer#setVisible()}. It is responsible for
188:             * showing and hiding the wizard container frame.
189:             *
190:             * @param visible Whether to show the frame - <code>true</code>, or to hide
191:             *      it - <code>false</code>.
192:             */
193:            @Override
194:            public void setVisible(final boolean visible) {
195:                super .setVisible(visible);
196:
197:                if (visible == false) {
198:                    dispose();
199:                }
200:            }
201:
202:            /**
203:             * {@inheritDoc}
204:             */
205:            public void updateWizardUi(final WizardUi wizardUi) {
206:                if (!SwingUtilities.isEventDispatchThread()) {
207:                    SwingUtilities.invokeLater(new Runnable() {
208:                        public void run() {
209:                            updateWizardUi(wizardUi);
210:                        }
211:                    });
212:                    return;
213:                }
214:
215:                // save the ui reference
216:                currentUi = wizardUi.getSwingUi(this );
217:
218:                final int currentHeight = getSize().height;
219:
220:                // update the frame title
221:                if (currentUi.getTitle() != null) {
222:                    setTitle(StringUtils.format(frameTitlePattern,
223:                            frameTitlePrefix, currentUi.getTitle()));
224:                } else {
225:                    setTitle(frameTitlePrefix);
226:                }
227:
228:                // change the panel
229:                contentPane.updatePanel(currentUi);
230:
231:                // resize the frame if needed
232:                final int neededMinimumHeight = this .getLayout()
233:                        .minimumLayoutSize(this ).getSize().height;
234:
235:                if (isResizable() && (neededMinimumHeight > currentHeight)) {
236:                    setPreferredSize(new Dimension(getSize().width,
237:                            neededMinimumHeight + EXTRA_SIZE));
238:                    pack();
239:                }
240:                contentPane.repaint();
241:
242:                // handle the default buttons - Enter
243:                getRootPane().setDefaultButton(
244:                        currentUi.getDefaultEnterButton());
245:
246:                // handle the default buttons - Escape
247:                getRootPane().getInputMap(JRootPane.WHEN_IN_FOCUSED_WINDOW)
248:                        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
249:                                CANCEL_ACTION_NAME);
250:                getRootPane().getActionMap().put(CANCEL_ACTION_NAME,
251:                        new AbstractAction() {
252:                            public void actionPerformed(ActionEvent event) {
253:                                final NbiButton button = currentUi
254:                                        .getDefaultEscapeButton();
255:                                if (button != null) {
256:                                    if (button.equals(getHelpButton())) {
257:                                        currentUi.evaluateHelpButtonClick();
258:                                    }
259:                                    if (button.equals(getBackButton())) {
260:                                        currentUi.evaluateBackButtonClick();
261:                                    }
262:                                    if (button.equals(getNextButton())) {
263:                                        currentUi.evaluateNextButtonClick();
264:                                    }
265:                                    if (button.equals(getCancelButton())) {
266:                                        currentUi.evaluateCancelButtonClick();
267:                                    }
268:                                }
269:                            }
270:                        });
271:
272:                // set the default focus for the current page
273:                if (currentUi.getDefaultFocusOwner() != null) {
274:                    currentUi.getDefaultFocusOwner().requestFocusInWindow();
275:                }
276:
277:                // a11y
278:                getAccessibleContext().setAccessibleName(currentUi.getTitle());
279:                getAccessibleContext().setAccessibleDescription(
280:                        currentUi.getDescription());
281:            }
282:
283:            /**
284:             * {@inheritDoc}
285:             */
286:            public NbiButton getHelpButton() {
287:                return contentPane.getHelpButton();
288:            }
289:
290:            /**
291:             * {@inheritDoc}
292:             */
293:            public NbiButton getBackButton() {
294:                return contentPane.getBackButton();
295:            }
296:
297:            /**
298:             * {@inheritDoc}
299:             */
300:            public NbiButton getNextButton() {
301:                return contentPane.getNextButton();
302:            }
303:
304:            /**
305:             * {@inheritDoc}
306:             */
307:            public NbiButton getCancelButton() {
308:                return contentPane.getCancelButton();
309:            }
310:
311:            // protected ////////////////////////////////////////////////////////////////////
312:            /**
313:             * Initializes and lays out the Swing components for the container frame. This
314:             * method also sets some frame properties which will be required at runtime,
315:             * such as size, position, etc.
316:             */
317:            private void initComponents() {
318:                try {
319:                    setDefaultCloseOperation(NbiFrame.DO_NOTHING_ON_CLOSE);
320:                    addWindowListener(new WindowAdapter() {
321:                        @Override
322:                        public void windowClosing(WindowEvent event) {
323:                            if (currentUi != null) {
324:                                if (contentPane.getCancelButton().isEnabled()) {
325:                                    currentUi.evaluateCancelButtonClick();
326:                                }
327:                            }
328:                        }
329:                    });
330:                } catch (SecurityException e) {
331:                    // we might fail here with a custom security manager (e.g. the netbeans
332:                    // one); in this case just log the exception and "let it be" (c)
333:                    ErrorManager.notifyDebug(ResourceUtils.getString(
334:                            SwingFrameContainer.class,
335:                            RESOURCE_ERROR_SET_CLOSE_OPERATION), e);
336:                }
337:                setSize(frameWidth, frameHeight);
338:                try {
339:                    setIconImage(new ImageIcon(frameIcon.toURI().toURL())
340:                            .getImage());
341:                } catch (MalformedURLException e) {
342:                    ErrorManager.notifyWarning(ResourceUtils.getString(
343:                            SwingFrameContainer.class,
344:                            RESOURCE_FAILED_TO_SET_FRAME_CONTAINER_ICON), e);
345:                }
346:
347:                final String resizable = System
348:                        .getProperty(WIZARD_FRAME_RESIZABLE_PROPERTY);
349:                if (resizable != null
350:                        && (resizable.equals("false") || resizable
351:                                .equals("FALSE"))) {
352:                    setResizable(false);
353:                }
354:
355:                contentPane = new WizardFrameContentPane();
356:                setContentPane(contentPane);
357:
358:                contentPane.getHelpButton().addActionListener(
359:                        new ActionListener() {
360:                            public void actionPerformed(ActionEvent event) {
361:                                currentUi.evaluateHelpButtonClick();
362:                            }
363:                        });
364:
365:                contentPane.getBackButton().addActionListener(
366:                        new ActionListener() {
367:                            public void actionPerformed(ActionEvent event) {
368:                                currentUi.evaluateBackButtonClick();
369:                            }
370:                        });
371:
372:                contentPane.getNextButton().addActionListener(
373:                        new ActionListener() {
374:                            public void actionPerformed(ActionEvent event) {
375:                                currentUi.evaluateNextButtonClick();
376:                            }
377:                        });
378:
379:                contentPane.getCancelButton().addActionListener(
380:                        new ActionListener() {
381:                            public void actionPerformed(ActionEvent event) {
382:                                currentUi.evaluateCancelButtonClick();
383:                            }
384:                        });
385:            }
386:
387:            /////////////////////////////////////////////////////////////////////////////////
388:            // Inner Classes
389:            /**
390:             * This class is an extension of {@link NbiFrameContentPane} which adds some
391:             * functionality specific to the wizard container's needs. It is used as the
392:             * content pane for the wizard frame.
393:             *
394:             * @author Kirill Sorokin
395:             * @since 1.0
396:             */
397:            public static class WizardFrameContentPane extends
398:                    NbiFrameContentPane {
399:                /**
400:                 * {@link NbiLabel} which would be used to display the
401:                 * {@link WizardComponent}'s title.
402:                 */
403:                private NbiLabel titleLabel;
404:
405:                /**
406:                 * {@link NbiTextPane} which would be used to display the
407:                 * {@link WizardComponent}'s description.
408:                 */
409:                private NbiTextPane descriptionPane;
410:
411:                /**
412:                 * Container for the title and description components.
413:                 */
414:                private NbiPanel titlePanel;
415:
416:                /**
417:                 * Container for the title and description images (left&right).
418:                 */
419:                private NbiPanel titleDescriptionImageRightPanel;
420:                private NbiPanel titleDescriptionImageLeftPanel;
421:
422:                /**
423:                 * Separator between the wizard page header (title and description) and the
424:                 * main wizard page contents.
425:                 */
426:                private NbiSeparator topSeparator;
427:
428:                /**
429:                 * Separator between the wizard page footer (standard wizard container
430:                 * buttons) and the main wizard page contents.
431:                 */
432:                private NbiSeparator bottomSeparator;
433:
434:                /**
435:                 * The standard <code>Help</code> button.
436:                 */
437:                private NbiButton helpButton;
438:
439:                /**
440:                 * The standard <code>Back</code> button.
441:                 */
442:                private NbiButton backButton;
443:
444:                /**
445:                 * The standard <code>Next</code> button.
446:                 */
447:                private NbiButton nextButton;
448:
449:                /**
450:                 * The standard <code>Cancel</code> button.
451:                 */
452:                private NbiButton cancelButton;
453:
454:                /**
455:                 * Spacer panel which used to correctly position the standard buttons.
456:                 */
457:                private NbiPanel spacerPanel;
458:
459:                /**
460:                 * Container for the standard buttons swing components.
461:                 */
462:                private NbiPanel buttonsPanel;
463:
464:                /**
465:                 * Reference to the {@link SwingUi} being currently displayed.
466:                 */
467:                private NbiPanel currentPanel;
468:
469:                /**
470:                 * Creates a new instance of {@link WizardFrameContentPane}. The default
471:                 * constructor simply initializes and lays out the swing components
472:                 * required by the content pane.
473:                 */
474:                public WizardFrameContentPane() {
475:                    initComponents();
476:                }
477:
478:                /**
479:                 *
480:                 * @param panel
481:                 */
482:                public void updatePanel(final SwingUi panel) {
483:                    if (currentPanel != null) {
484:                        remove(currentPanel);
485:                    }
486:                    currentPanel = panel;
487:
488:                    if (panel.getTitle() != null) {
489:                        titleLabel.setText(panel.getTitle());
490:                        descriptionPane.setText(panel.getDescription());
491:
492:                        titlePanel.setVisible(true);
493:                        topSeparator.setVisible(true);
494:
495:                        currentPanel.setOpaque(false);
496:                    } else {
497:                        titlePanel.setVisible(false);
498:                        topSeparator.setVisible(false);
499:
500:                        currentPanel.setOpaque(true);
501:                        currentPanel.setBackground(Color.WHITE);
502:                    }
503:
504:                    add(currentPanel, BorderLayout.CENTER);
505:
506:                    validate();
507:                }
508:
509:                /**
510:                 * Returns the Swing implementation of the standard <code>Help</code>
511:                 * button. This method is called by the {@link SwingFrameContainer} when it
512:                 * needs to get the handle of the button.
513:                 *
514:                 * @return <code>Help</code> button instance.
515:                 * @see SwingFrameContainer#getHelpButton.
516:                 */
517:                public NbiButton getHelpButton() {
518:                    return helpButton;
519:                }
520:
521:                /**
522:                 * Returns the Swing implementation of the standard <code>Back</code>
523:                 * button. This method is called by the {@link SwingFrameContainer} when it
524:                 * needs to get the handle of the button.
525:                 *
526:                 * @return <code>Back</code> button instance.
527:                 * @see SwingFrameContainer#getBackButton.
528:                 */
529:                public NbiButton getBackButton() {
530:                    return backButton;
531:                }
532:
533:                /**
534:                 * Returns the Swing implementation of the standard <code>Next</code>
535:                 * button. This method is called by the {@link SwingFrameContainer} when it
536:                 * needs to get the handle of the button.
537:                 *
538:                 * @return <code>Next</code> button instance.
539:                 * @see SwingFrameContainer#getNextButton.
540:                 */
541:                public NbiButton getNextButton() {
542:                    return nextButton;
543:                }
544:
545:                /**
546:                 * Returns the Swing implementation of the standard <code>Cancel</code>
547:                 * button. This method is called by the {@link SwingFrameContainer} when it
548:                 * needs to get the handle of the button.
549:                 *
550:                 * @return <code>Cancel</code> button instance.
551:                 * @see SwingFrameContainer#getCancelButton.
552:                 */
553:                public NbiButton getCancelButton() {
554:                    return cancelButton;
555:                }
556:
557:                // private //////////////////////////////////////////////////////////////////
558:                /**
559:                 * Initializes and lays out the swing components required by the content
560:                 * pane.
561:                 */
562:                private void initComponents() {
563:                    // titleLabel ///////////////////////////////////////////////////////////
564:                    titleLabel = new NbiLabel();
565:                    titleLabel.setFocusable(true);
566:                    titleLabel.setFont(titleLabel.getFont().deriveFont(
567:                            Font.BOLD));
568:
569:                    // descriptionPane //////////////////////////////////////////////////////
570:                    descriptionPane = new NbiTextPane();
571:
572:                    // titlePanel ///////////////////////////////////////////////////////////
573:                    titlePanel = new NbiPanel();
574:                    titlePanel.setBackground(Color.WHITE);
575:                    titlePanel.setLayout(new GridBagLayout());
576:                    titlePanel.setOpaque(true);
577:
578:                    final String leftImageUri = System
579:                            .getProperty(WIZARD_FRAME_HEAD_LEFT_IMAGE_URI_PROPERTY);
580:                    int titlePanelDx = 0;
581:                    if (leftImageUri != null) {
582:                        titleDescriptionImageLeftPanel = new NbiPanel();
583:                        titleDescriptionImageLeftPanel.setBackgroundImage(
584:                                leftImageUri, NbiPanel.ANCHOR_TOP_RIGHT);
585:                        final ImageIcon icon = titleDescriptionImageLeftPanel
586:                                .getBackgroundImage(NbiPanel.ANCHOR_TOP_RIGHT);
587:                        titleDescriptionImageLeftPanel
588:                                .setPreferredSize(new Dimension(icon
589:                                        .getIconWidth(), icon.getIconHeight()));
590:                        titleDescriptionImageLeftPanel
591:                                .setPreferredSize(new Dimension(icon
592:                                        .getIconWidth(), icon.getIconHeight()));
593:                        titleDescriptionImageLeftPanel
594:                                .setMaximumSize(new Dimension(icon
595:                                        .getIconWidth(), icon.getIconHeight()));
596:                        titleDescriptionImageLeftPanel
597:                                .setMinimumSize(new Dimension(icon
598:                                        .getIconWidth(), 0));
599:                        titleDescriptionImageLeftPanel.setSize(new Dimension(
600:                                icon.getIconWidth(), icon.getIconHeight()));
601:                        titleDescriptionImageLeftPanel.setOpaque(false);
602:                        titlePanel.add(titleDescriptionImageLeftPanel,
603:                                new GridBagConstraints(titlePanelDx++, 0, // x, y
604:                                        1, 2, // width, height
605:                                        0.0, 0.0, // weight-x, weight-y
606:                                        GridBagConstraints.NORTH, // anchor
607:                                        GridBagConstraints.BOTH, // fill
608:                                        new Insets(0, 0, 0, 0), // padding
609:                                        0, 0)); // padx, pady - ???
610:                    }
611:
612:                    final String rightImageUri = System
613:                            .getProperty(WIZARD_FRAME_HEAD_RIGHT_IMAGE_URI_PROPERTY);
614:                    if (rightImageUri != null) {
615:                        titleDescriptionImageRightPanel = new NbiPanel();
616:                        titleDescriptionImageRightPanel.setBackgroundImage(
617:                                rightImageUri, NbiPanel.ANCHOR_TOP_RIGHT);
618:                        final ImageIcon icon = titleDescriptionImageRightPanel
619:                                .getBackgroundImage(NbiPanel.ANCHOR_TOP_RIGHT);
620:                        titleDescriptionImageRightPanel
621:                                .setPreferredSize(new Dimension(icon
622:                                        .getIconWidth(), icon.getIconHeight()));
623:                        titleDescriptionImageRightPanel
624:                                .setPreferredSize(new Dimension(icon
625:                                        .getIconWidth(), icon.getIconHeight()));
626:                        titleDescriptionImageRightPanel
627:                                .setMaximumSize(new Dimension(icon
628:                                        .getIconWidth(), icon.getIconHeight()));
629:                        titleDescriptionImageRightPanel
630:                                .setMinimumSize(new Dimension(icon
631:                                        .getIconWidth(), 0));
632:                        titleDescriptionImageRightPanel.setSize(new Dimension(
633:                                icon.getIconWidth(), icon.getIconHeight()));
634:                        titleDescriptionImageRightPanel.setOpaque(false);
635:                        titlePanel.add(titleDescriptionImageRightPanel,
636:                                new GridBagConstraints(titlePanelDx + 1, 0, // x, y
637:                                        1, 2, // width, height
638:                                        0.0, 0.0, // weight-x, weight-y
639:                                        GridBagConstraints.NORTH, // anchor
640:                                        GridBagConstraints.BOTH, // fill
641:                                        new Insets(0, 0, 0, 0), // padding
642:                                        0, 0)); // padx, pady - ???
643:                    }
644:
645:                    // topSeparator /////////////////////////////////////////////////////////
646:                    topSeparator = new NbiSeparator();
647:                    if (SystemUtils.isMacOS()) {
648:                        // JSeparator`s height on Aqua L&F equals to 12px which is too much in SwingFrameContainer
649:                        // thus we descrease it to 7px
650:                        // TODO: possibly move this code to NbiSeparator later
651:                        Dimension d = topSeparator.getPreferredSize();
652:                        if (d != null && d.getHeight() == 12) {
653:                            d.setSize(d.getWidth(), 7);
654:                            topSeparator.setPreferredSize(d);
655:                        }
656:                    }
657:                    titlePanel.add(titleLabel, new GridBagConstraints(
658:                            titlePanelDx, 0, // x, y
659:                            1, 1, // width, height
660:                            1.0, 0.0, // weight-x, weight-y
661:                            GridBagConstraints.LINE_START, // anchor
662:                            GridBagConstraints.BOTH, // fill
663:                            new Insets(11, 11, 0, 11), // padding
664:                            0, 0)); // padx, pady - ???
665:                    titlePanel.add(descriptionPane, new GridBagConstraints(
666:                            titlePanelDx, 1, // x, y
667:                            1, 1, // width, height
668:                            1.0, 1.0, // weight-x, weight-y
669:                            GridBagConstraints.PAGE_START, // anchor
670:                            GridBagConstraints.BOTH, // fill
671:                            new Insets(6, 22, 4, 11), // padding
672:                            0, 0)); // padx, pady - ???
673:                    titlePanel.add(topSeparator, new GridBagConstraints(0, 2, // x, y
674:                            2 + titlePanelDx, 1, // width, height
675:                            1.0, 0.0, // weight-x, weight-y
676:                            GridBagConstraints.CENTER, // anchor
677:                            GridBagConstraints.HORIZONTAL, // fill
678:                            new Insets(0, 0, 0, 0), // padding
679:                            0, 0)); // padx, pady - ???
680:
681:                    // bottomSeparator //////////////////////////////////////////////////////
682:                    bottomSeparator = new NbiSeparator();
683:                    if (SystemUtils.isMacOS()) {
684:                        // JSeparator`s height on Aqua L&F equals to 12px which is too much in SwingFrameContainer
685:                        // thus we descrease it to 7px
686:                        // TODO: possibly move this code to NbiSeparator later
687:                        Dimension d = topSeparator.getPreferredSize();
688:                        if (d != null && d.getHeight() == 12) {
689:                            d.setSize(d.getWidth(), 7);
690:                            topSeparator.setPreferredSize(d);
691:                        }
692:                    }
693:                    // helpButton ///////////////////////////////////////////////////////////
694:                    helpButton = new NbiButton();
695:
696:                    // backButton ///////////////////////////////////////////////////////////
697:                    backButton = new NbiButton();
698:
699:                    // nextButton ///////////////////////////////////////////////////////////
700:                    nextButton = new NbiButton();
701:
702:                    // cancelButton /////////////////////////////////////////////////////////
703:                    cancelButton = new NbiButton();
704:
705:                    // spacerPanel //////////////////////////////////////////////////////////
706:                    spacerPanel = new NbiPanel();
707:
708:                    // buttonsPanel /////////////////////////////////////////////////////////
709:                    buttonsPanel = new NbiPanel();
710:
711:                    buttonsPanel.add(bottomSeparator, new GridBagConstraints(0,
712:                            0, // x, y
713:                            5, 1, // width, height
714:                            1.0, 0.0, // weight-x, weight-y
715:                            GridBagConstraints.CENTER, // anchor
716:                            GridBagConstraints.HORIZONTAL, // fill
717:                            new Insets(0, 0, 0, 0), // padding
718:                            0, 0)); // padx, pady - ???
719:                    buttonsPanel.add(helpButton, new GridBagConstraints(0, 1, // x, y
720:                            1, 1, // width, height
721:                            0.0, 0.0, // weight-x, weight-y
722:                            GridBagConstraints.CENTER, // anchor
723:                            GridBagConstraints.NONE, // fill
724:                            new Insets(11, 11, 11, 11), // padding
725:                            0, 0)); // padx, pady - ???
726:                    buttonsPanel.add(spacerPanel, new GridBagConstraints(1, 1, // x, y
727:                            1, 1, // width, height
728:                            1.0, 0.0, // weight-x, weight-y
729:                            GridBagConstraints.CENTER, // anchor
730:                            GridBagConstraints.BOTH, // fill
731:                            new Insets(0, 0, 0, 0), // padding
732:                            0, 0)); // padx, pady - ???
733:                    buttonsPanel.add(backButton, new GridBagConstraints(2, 1, // x, y
734:                            1, 1, // width, height
735:                            0.0, 0.0, // weight-x, weight-y
736:                            GridBagConstraints.CENTER, // anchor
737:                            GridBagConstraints.NONE, // fill
738:                            new Insets(11, 0, 11, 6), // padding
739:                            0, 0)); // padx, pady - ???
740:                    buttonsPanel.add(nextButton, new GridBagConstraints(3, 1, // x, y
741:                            1, 1, // width, height
742:                            0.0, 0.0, // weight-x, weight-y
743:                            GridBagConstraints.CENTER, // anchor
744:                            GridBagConstraints.NONE, // fill
745:                            new Insets(11, 0, 11, 11), // padding
746:                            0, 0)); // padx, pady - ???
747:                    buttonsPanel.add(cancelButton, new GridBagConstraints(4, 1, // x, y
748:                            1, 1, // width, height
749:                            0.0, 0.0, // weight-x, weight-y
750:                            GridBagConstraints.CENTER, // anchor
751:                            GridBagConstraints.NONE, // fill
752:                            new Insets(11, 0, 11, 11), // padding
753:                            0, 0)); // padx, pady - ???
754:
755:                    // currentPanel /////////////////////////////////////////////////////////
756:                    currentPanel = new NbiPanel();
757:
758:                    // this /////////////////////////////////////////////////////////////////
759:                    setLayout(new BorderLayout());
760:
761:                    add(titlePanel, BorderLayout.PAGE_START);
762:                    add(currentPanel, BorderLayout.CENTER);
763:                    add(buttonsPanel, BorderLayout.PAGE_END);
764:
765:                    // debugging plug ///////////////////////////////////////////////////////
766:                    //KeyboardFocusManager.getCurrentKeyboardFocusManager().
767:                    //        addPropertyChangeListener(new PropertyChangeListener() {
768:                    //    public void propertyChange(PropertyChangeEvent event) {
769:                    //        if (event.getPropertyName().equals("focusOwner")) {
770:                    //            if (event.getNewValue() != null) {
771:                    //                System.out.println(event.getNewValue());
772:                    //            }
773:                    //        }
774:                    //    }
775:                    //});
776:                }
777:            }
778:
779:            /////////////////////////////////////////////////////////////////////////////////
780:            // Constants
781:            /**
782:             * Name of the system property which is expected to contain the desired value
783:             * for the initial width of the wizard frame.
784:             */
785:            public static final String WIZARD_FRAME_WIDTH_PROPERTY = "nbi.wizard.ui.swing.frame.width"; // NOI18N
786:
787:            /**
788:             * Name of the system property which is expected to contain the desired value
789:             * for the minimum width of the wizard frame.
790:             */
791:            public static final String WIZARD_FRAME_MINIMUM_WIDTH_PROPERTY = "nbi.wizard.ui.swing.frame.minimum.width"; // NOI18N
792:
793:            /**
794:             * Name of the system property which is expected to contain the desired value
795:             * for the maximum width of the wizard frame.
796:             */
797:            public static final String WIZARD_FRAME_MAXIMUM_WIDTH_PROPERTY = "nbi.wizard.ui.swing.frame.maximum.width"; // NOI18N
798:
799:            /**
800:             * Name of the system property which is expected to contain the desired value
801:             * for the initial height of the wizard frame.
802:             */
803:            public static final String WIZARD_FRAME_HEIGHT_PROPERTY = "nbi.wizard.ui.swing.frame.height"; // NOI18N
804:
805:            /**
806:             * Name of the system property which is expected to contain the desired value
807:             * for the minimum height of the wizard frame.
808:             */
809:            public static final String WIZARD_FRAME_MINIMUM_HEIGHT_PROPERTY = "nbi.wizard.ui.swing.frame.minimum.height"; // NOI18N
810:
811:            /**
812:             * Name of the system property which is expected to contain the desired value
813:             * for the maximum height of the wizard frame.
814:             */
815:            public static final String WIZARD_FRAME_MAXIMUM_HEIGHT_PROPERTY = "nbi.wizard.ui.swing.frame.maximum.height"; // NOI18N
816:
817:            /**
818:             * Name of the system property which is expected to contain the desired value
819:             * for the URI of the wizard frame icon.
820:             */
821:            public static final String WIZARD_FRAME_ICON_URI_PROPERTY = "nbi.wizard.ui.swing.frame.icon"; // NOI18N
822:
823:            /**
824:             * Name of the system property which is expected to contain the desired value
825:             * for the standard prefix of the wizard frame's title.
826:             */
827:            public static final String WIZARD_FRAME_TITLE_PREFIX_PROPERTY = "nbi.wizard.ui.swing.frame.title.prefix"; // NOI18N
828:
829:            /**
830:             * Name of the system property which is expected to contain the desired value
831:             * for the URI of the wizard frame head background image (right side).
832:             */
833:            public static final String WIZARD_FRAME_HEAD_RIGHT_IMAGE_URI_PROPERTY = "nbi.wizard.ui.swing.frame.head.right.image"; // NOI18N
834:            /**
835:             * Name of the system property which is expected to contain the desired value
836:             * for the URI of the wizard frame head background image (left side).
837:             */
838:            public static final String WIZARD_FRAME_HEAD_LEFT_IMAGE_URI_PROPERTY = "nbi.wizard.ui.swing.frame.head.left.image"; // NOI18N
839:
840:            /**
841:             * Name of the system property which is expected to contain the desired value
842:             * for the pattern for merging the standard title prefix with the component's
843:             * title.
844:             */
845:            public static final String WIZARD_FRAME_TITLE_PATTERN_PROPERTY = "nbi.wizard.ui.swing.frame.title.pattern"; // NOI18N
846:
847:            /**
848:             * Name of the system property which is expected to contain the desired value
849:             * for the making the wizard window be resizable.
850:             * <br>If this property is not set at all or set to any string different from
851:             * "false" and "FALSE" then the wizard is resiazable.
852:             */
853:            public static final String WIZARD_FRAME_RESIZABLE_PROPERTY = "nbi.wizard.ui.swing.frame.resizable"; // NOI18N
854:
855:            /**
856:             * Default value for the wizard frame's initial width.
857:             */
858:            public static final int DEFAULT_WIZARD_FRAME_WIDTH = NbiFrame.DEFAULT_FRAME_WIDTH;
859:
860:            /**
861:             * Default value for the wizard frame's minimum width.
862:             */
863:            public static final int DEFAULT_WIZARD_FRAME_MINIMUM_WIDTH = NbiFrame.DEFAULT_FRAME_MINIMUM_WIDTH;
864:
865:            /**
866:             * Default value for the wizard frame's maximum width.
867:             */
868:            public static final int DEFAULT_WIZARD_FRAME_MAXIMUM_WIDTH = NbiFrame.DEFAULT_FRAME_MAXIMUM_WIDTH;
869:
870:            /**
871:             * Default value for the wizard frame's initial height.
872:             */
873:            public static final int DEFAULT_WIZARD_FRAME_HEIGHT = NbiFrame.DEFAULT_FRAME_HEIGHT;
874:
875:            /**
876:             * Default value for the wizard frame's minimum height.
877:             */
878:            public static final int DEFAULT_WIZARD_FRAME_MINIMUM_HEIGHT = NbiFrame.DEFAULT_FRAME_MINIMUM_WIDTH;
879:
880:            /**
881:             * Default value for the wizard frame's maximum height.
882:             */
883:            public static final int DEFAULT_WIZARD_FRAME_MAXIMUM_HEIGHT = NbiFrame.DEFAULT_FRAME_MAXIMUM_HEIGHT;
884:
885:            /**
886:             * Default value for the wizard frame's icon's URI.
887:             */
888:            public static final String DEFAULT_WIZARD_FRAME_ICON_URI = NbiFrame.DEFAULT_FRAME_ICON_URI;
889:
890:            /**
891:             * Default value for the wizard frame's standard title prefix.
892:             */
893:            public static final String DEFAULT_WIZARD_FRAME_TITLE_PREFIX = ResourceUtils
894:                    .getString(SwingFrameContainer.class,
895:                            "SFC.frame.title.prefix"); // NOI18N
896:
897:            /**
898:             * Default value for the pattern for merging the standard title prefix with the
899:             * component's title.
900:             */
901:            public static final String DEFAULT_WIZARD_FRAME_TITLE_PATTERN = ResourceUtils
902:                    .getString(SwingFrameContainer.class,
903:                            "SFC.frame.title.pattern"); // NOI18N
904:
905:            // private //////////////////////////////////////////////////////////////////////
906:            /**
907:             * Name of a resource bundle entry.
908:             */
909:            private static final String RESOURCE_FAILED_TO_PARSE_SYSTEM_PROPERTY = "SFC.error.failed.to.parse.property"; // NOI18N
910:
911:            /**
912:             * Name of a resource bundle entry.
913:             */
914:            private static final String RESOURCE_FAILED_TO_DOWNLOAD_WIZARD_ICON = "SFC.error.failed.to.download.icon"; // NOI18N
915:            private static final String RESOURCE_ERROR_SET_CLOSE_OPERATION = "SFC.error.close.operation"; //NOI18N
916:            private static final String RESOURCE_FAILED_TO_SET_FRAME_CONTAINER_ICON = "SFC.error.failed.to.set.icon";//NOI18N
917:            /**
918:             * Name of the {@link AbstractAction} which is invoked when the user presses the
919:             * <code>Escape</code> button.
920:             */
921:            private static final String CANCEL_ACTION_NAME = "evaluate.cancel"; // NOI18N
922:
923:            private static final int EXTRA_SIZE = 15;
924:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.