Package br.msf.netbeans.licenseupdater

Source Code of br.msf.netbeans.licenseupdater.LicenseUpdaterWizardAction

/*
* license-updater - Copyright (c) 2012 MSF. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
package br.msf.netbeans.licenseupdater;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;

/**
* <p>TODO
*
* @author Marcius da Silva da Fonseca (sf.marcius@gmail.com)
* @version 1.0
* @since license-updater-1.0
*/
// An example action demonstrating how the wizard could be called from within
// your code. You can move the code below wherever you need, or register an action:
// @ActionID(category="Source", id="br.msf.netbeans.licenseupdater.LicenseUpdaterWizardAction")
// @ActionRegistration(displayName="Open LicenseUpdater Wizard")
// @ActionReference(path="Menu/Source", position=0)
@ActionID(category = "Source", id = "br.msf.netbeans.licenseupdater.LicenseUpdaterWizardAction")
@ActionRegistration(iconBase = "br/msf/netbeans/licenseupdater/icon.png", displayName = "#CTL_UpdateLicences")
@Messages("CTL_UpdateLicences=Update Licences")
@ActionReferences({
    @ActionReference(path = "Menu/Source", position = 0)
})
public final class LicenseUpdaterWizardAction implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
        panels.add(new LicenseUpdaterWizardPanel1());
        String[] steps = new String[panels.size()];
        for (int i = 0; i < panels.size(); i++) {
            Component c = panels.get(i).getComponent();
            // Default step name to component name of panel.
            steps[i] = c.getName();
            if (c instanceof JComponent) { // assume Swing components
                JComponent jc = (JComponent) c;
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
                jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
                jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
            }
        }
        WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<WizardDescriptor>(panels));
        // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
        wiz.setTitleFormat(new MessageFormat("{0}"));
        wiz.setTitle("...dialog title...");
        if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {
            LicenseUpdaterParams params = (LicenseUpdaterParams) wiz.getProperty("params");
            new LicenseController(params).doTheTrick();
            params.store();
        }
    }
}
TOP

Related Classes of br.msf.netbeans.licenseupdater.LicenseUpdaterWizardAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.