001: /*
002: * Sun Public License Notice
003: *
004: * The contents of this file are subject to the Sun Public License
005: * Version 1.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://www.sun.com/
008: *
009: * The Original Code is NetBeans. The Initial Developer of the Original
010: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
011: * Microsystems, Inc. All Rights Reserved.
012: If you wish your version of this file to be governed by only the CDDL
013: or only the GPL Version 2, indicate your decision by adding
014: "[Contributor] elects to include this software in this distribution
015: under the [CDDL or GPL Version 2] license." If you do not indicate a
016: single choice of license, a recipient has the option to distribute
017: your version of this file under either the CDDL, the GPL Version 2 or
018: to extend the choice of license to its licensees as provided above.
019: However, if you add GPL Version 2 code and therefore, elected the GPL
020: Version 2 license, then the option applies only if the new code is
021: made subject to such option by the copyright holder.
022: If you wish your version of this file to be governed by only the CDDL
023: or only the GPL Version 2, indicate your decision by adding
024: "[Contributor] elects to include this software in this distribution
025: under the [CDDL or GPL Version 2] license." If you do not indicate a
026: single choice of license, a recipient has the option to distribute
027: your version of this file under either the CDDL, the GPL Version 2 or
028: to extend the choice of license to its licensees as provided above.
029: However, if you add GPL Version 2 code and therefore, elected the GPL
030: Version 2 license, then the option applies only if the new code is
031: made subject to such option by the copyright holder.
032: */
033: package org.netbeans.modules.mashup.db.wizard;
034:
035: import java.awt.Component;
036: import java.awt.Dialog;
037: import java.text.MessageFormat;
038: import javax.swing.JComponent;
039:
040: import net.java.hulp.i18n.Logger;
041: import org.netbeans.modules.etl.logger.Localizer;
042: import org.netbeans.modules.etl.logger.LogUtil;
043: import org.netbeans.modules.mashup.db.ui.wizard.SelectDatabasePanel;
044: import org.openide.DialogDisplayer;
045: import org.openide.WizardDescriptor;
046: import org.openide.util.HelpCtx;
047: import org.openide.util.actions.CallableSystemAction;
048:
049: /**
050: *
051: * @author ks161616
052: */
053: public final class FlatfileDBViewerAction extends CallableSystemAction {
054: private static transient final Logger mLogger = LogUtil
055: .getLogger(NewFlatfileTableAction.class.getName());
056: private static transient final Localizer mLoc = Localizer.get();
057: public String nbBundle1 = mLoc.t("PRSR001: Mashup Database Viewer");
058: private WizardDescriptor.Panel[] panels;
059:
060: public void performAction() {
061: WizardDescriptor wizardDescriptor = new WizardDescriptor(
062: getPanels());
063: // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
064: wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
065: wizardDescriptor.setTitle(Localizer.parse(nbBundle1));
066: Dialog dialog = DialogDisplayer.getDefault().createDialog(
067: wizardDescriptor);
068: dialog
069: .getAccessibleContext()
070: .setAccessibleDescription(
071: "This is the dialog which displays mashupdb information");
072: dialog.setVisible(true);
073: dialog.toFront();
074: boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
075: if (!cancelled) {
076: // do something
077: }
078: }
079:
080: /**
081: * Initialize panels representing individual wizard's steps and sets
082: * various properties for them influencing wizard appearance.
083: */
084: private WizardDescriptor.Panel[] getPanels() {
085: if (panels == null) {
086: panels = new WizardDescriptor.Panel[] {
087: new SelectDatabasePanel(),
088: new FlatfileViewerTreePanel() };
089: String[] steps = new String[panels.length];
090: for (int i = 0; i < panels.length; i++) {
091: Component c = panels[i].getComponent();
092: // Default step name to component name of panel. Mainly useful
093: // for getting the name of the target chooser to appear in the
094: // list of steps.
095: steps[i] = c.getName();
096: if (c instanceof JComponent) { // assume Swing components
097: JComponent jc = (JComponent) c;
098: // Sets step number of a component
099: jc.putClientProperty(
100: "WizardPanel_contentSelectedIndex",
101: new Integer(i));
102: // Sets steps names for a panel
103: jc.putClientProperty("WizardPanel_contentData",
104: steps);
105: // Turn on subtitle creation on each step
106: jc.putClientProperty("WizardPanel_autoWizardStyle",
107: Boolean.TRUE);
108: // Show steps on the left side with the image on the background
109: jc.putClientProperty(
110: "WizardPanel_contentDisplayed",
111: Boolean.TRUE);
112: // Turn on numbering of all steps
113: jc.putClientProperty("WizardPanel_contentNumbered",
114: Boolean.TRUE);
115: }
116: }
117: }
118: return panels;
119: }
120:
121: public String getName() {
122: return Localizer.parse(nbBundle1);
123: }
124:
125: @Override
126: public String iconResource() {
127: return null;
128: }
129:
130: public HelpCtx getHelpCtx() {
131: return HelpCtx.DEFAULT_HELP;
132: }
133:
134: @Override
135: protected boolean asynchronous() {
136: return false;
137: }
138: }
|