001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: /*
021: *
022: * Copyright 2005 Sun Microsystems, Inc.
023: *
024: * Licensed under the Apache License, Version 2.0 (the "License");
025: * you may not use this file except in compliance with the License.
026: * You may obtain a copy of the License at
027: *
028: * http://www.apache.org/licenses/LICENSE-2.0
029: *
030: * Unless required by applicable law or agreed to in writing, software
031: * distributed under the License is distributed on an "AS IS" BASIS,
032: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
033: * See the License for the specific language governing permissions and
034: * limitations under the License.
035: *
036: */
037: package org.netbeans.modules.jdbcwizard.wizards;
038:
039: import java.awt.Dimension;
040: import java.text.MessageFormat;
041: import java.util.MissingResourceException;
042: import org.openide.WizardDescriptor;
043: import org.openide.util.NbBundle;
044:
045: /**
046: * Abstract subclass of NetBeans wizard descriptor. JDBC wizard descriptors should be concrete
047: * subclasses of this class.
048: */
049: public abstract class JDBCWizardDescriptor extends WizardDescriptor {
050:
051: /* Manages navigation of wizard panels */
052: private WizardDescriptor.Iterator iterator;
053:
054: /**
055: * Constructs an instance of JDBCWizardDescriptor with the given iterator and context.
056: *
057: * @param iter WizardDescriptor.Iterator instance to cycle through the panels defined by this
058: * descriptor
059: * @param context JDBCWizardContext to serve as intermediate storage for data collected by
060: * panels in this descriptor.
061: */
062: public JDBCWizardDescriptor(final WizardDescriptor.Iterator iter,
063: final Object context) {
064: super (iter, context);
065: this .iterator = iter;
066: }
067:
068: /**
069: * Overrides parent implementation to set customized look and feel settings.
070: *
071: * @see org.openide.WizardDescriptor#initialize
072: */
073: protected void initialize() {
074: this .initializeLookAndFeel();
075:
076: super .initialize();
077: }
078:
079: /**
080: * Initializes look-and-feel of wizard panels.
081: */
082: protected void initializeLookAndFeel() {
083:
084: try {
085: // Sets message format used for panel title; {0} indicates component
086: // name, if any; {1} indicates step info as provided by iterator.
087: this .setTitleFormat(new MessageFormat(NbBundle.getMessage(
088: JDBCWizardDescriptor.class,
089: "MSG_titleformat_wiz_default")));
090: } catch (final MissingResourceException e) {
091:
092: }
093:
094: // Number the steps.
095: this .putProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N
096:
097: // Optional: set the size of the left pane explicitly:
098: this .putProperty("WizardPanel_leftDimension", new Dimension(
099: 184, 500)); // NOI18N
100:
101: // Optional: show a help tab with special info about the pane:
102: this .putProperty("WizardPanel_helpDisplayed", Boolean.TRUE); // NOI18N
103:
104: // Make the left pane appear:
105: this .putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N
106:
107: // Make the left pane show list of steps etc.:
108: this .putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N
109: }
110:
111: // Called when user moves forward or backward etc.:
112: /**
113: * Called whenever user chooses a navigation button (back, next, etc.) on the wizard.
114: *
115: * @see org.openide.WizardDescriptor#updateState
116: */
117: protected void updateState() {
118: if (this .iterator instanceof JDBCWizardIterator) {
119: final JDBCWizardIterator myIterator = (JDBCWizardIterator) this .iterator;
120:
121: // Make the left pane show list of steps etc.:
122: this .putProperty("WizardPanel_contentData", myIterator
123: .getSteps()); // NOI18N
124: this .putProperty("WizardPanel_contentSelectedIndex",
125: Integer.valueOf(String.valueOf(myIterator
126: .getIndex()))); // NOI18N
127: }
128:
129: super.updateState();
130: }
131: }
|