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: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 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: package org.netbeans.modules.etl.ui.view.wizards;
042:
043: import java.awt.Dimension;
044: import java.text.MessageFormat;
045: import java.util.MissingResourceException;
046: import net.java.hulp.i18n.Logger;
047: import org.netbeans.modules.etl.logger.Localizer;
048: import org.netbeans.modules.etl.logger.LogUtil;
049: import org.openide.WizardDescriptor;
050:
051: /**
052: * Abstract subclass of NetBeans wizard descriptor. ETL wizard descriptors should be
053: * concrete subclasses of this class.
054: */
055: public abstract class ETLWizardDescriptor extends WizardDescriptor {
056: /* Logging category string */
057:
058: private static final String LOG_CATEGORY = ETLWizardDescriptor.class
059: .getName();
060: private static transient final Logger mLogger = LogUtil
061: .getLogger(ETLWizardDescriptor.class.getName());
062: private static transient final Localizer mLoc = Localizer.get();
063: /* Manages navigation of wizard panels */
064: private WizardDescriptor.Iterator iterator;
065:
066: /**
067: * Constructs an instance of ETLWizardDescriptor with the given iterator and context.
068: *
069: * @param iter WizardDescriptor.Iterator instance to cycle through the panels defined
070: * by this descriptor
071: * @param context ETLWizardContext to serve as intermediate storage for data collected
072: * by panels in this descriptor.
073: */
074: public ETLWizardDescriptor(WizardDescriptor.Iterator iter,
075: Object context) {
076: super (iter, context);
077: this .iterator = iter;
078: }
079:
080: /**
081: * Overrides parent implementation to set customized look and feel settings.
082: *
083: * @see org.openide.WizardDescriptor#initialize
084: */
085: protected void initialize() {
086: initializeLookAndFeel();
087:
088: super .initialize();
089: }
090:
091: /**
092: * Initializes look-and-feel of wizard panels.
093: */
094: protected void initializeLookAndFeel() {
095:
096: try {
097: String nbBundle1 = mLoc.t("PRSR001: {0}");
098: // Sets message format used for panel title; {0} indicates component
099: // name, if any; {1} indicates step info as provided by iterator.
100: setTitleFormat(new MessageFormat(Localizer.parse(nbBundle1)));
101: } catch (MissingResourceException e) {
102: mLogger
103: .errorNoloc(
104: mLoc
105: .t(
106: "PRSR040: Could not locate key for title format.{0}",
107: LOG_CATEGORY), e);
108: }
109:
110: // Number the steps.
111: putProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N
112:
113: // Optional: set the size of the left pane explicitly:
114: putProperty("WizardPanel_leftDimension",
115: new Dimension(184, 500)); // NOI18N
116:
117: // Optional: show a help tab with special info about the pane:
118: // putProperty("WizardPanel_helpDisplayed", Boolean.TRUE); // NOI18N
119:
120: // Make the left pane appear:
121: putProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N
122:
123: // Make the left pane show list of steps etc.:
124: putProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N
125: }
126:
127: // Called when user moves forward or backward etc.:
128: /**
129: * Called whenever user chooses a navigation button (back, next, etc.) on the wizard.
130: *
131: * @see org.openide.WizardDescriptor#updateState
132: */
133: protected void updateState() {
134: if (iterator instanceof ETLWizardIterator) {
135: ETLWizardIterator myIterator = (ETLWizardIterator) iterator;
136:
137: // Make the left pane show list of steps etc.:
138: putProperty("WizardPanel_contentData", myIterator
139: .getSteps()); // NOI18N
140: putProperty("WizardPanel_contentSelectedIndex",
141: new Integer(myIterator.getIndex())); // NOI18N
142: }
143:
144: super.updateState();
145: }
146: }
|