Search in sources :

Example 1 with WizardImporterBuilder

use of org.gephi.io.importer.spi.WizardImporterBuilder in project gephi by gephi.

the class ImportWizard method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    WizardIterator wizardIterator = new WizardIterator();
    WizardDescriptor wizardDescriptor = new WizardDescriptor(wizardIterator);
    wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
    wizardDescriptor.setTitle(NbBundle.getMessage(getClass(), "ImportWizard.wizard.title"));
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        ImporterWizardUI wizardUI = wizardIterator.getCurrentWizardUI();
        //Get Importer
        WizardImporter importer = null;
        for (WizardImporterBuilder wizardBuilder : Lookup.getDefault().lookupAll(WizardImporterBuilder.class)) {
            WizardImporter im = wizardBuilder.buildImporter();
            if (wizardUI.isUIForImporter(im)) {
                importer = im;
            }
        }
        if (importer == null) {
            NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(getClass(), "ImportWizard.error_no_matching_importer"), NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notify(msg);
            return;
        }
        //Unsetup
        wizardIterator.unsetupPanels(importer);
        ImportControllerUI importControllerUI = Lookup.getDefault().lookup(ImportControllerUI.class);
        importControllerUI.importWizard(importer);
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) MessageFormat(java.text.MessageFormat) Dialog(java.awt.Dialog) WizardImporter(org.gephi.io.importer.spi.WizardImporter) ImportControllerUI(org.gephi.desktop.importer.api.ImportControllerUI) WizardDescriptor(org.openide.WizardDescriptor) ImporterWizardUI(org.gephi.io.importer.spi.ImporterWizardUI) WizardImporterBuilder(org.gephi.io.importer.spi.WizardImporterBuilder)

Aggregations

Dialog (java.awt.Dialog)1 MessageFormat (java.text.MessageFormat)1 ImportControllerUI (org.gephi.desktop.importer.api.ImportControllerUI)1 ImporterWizardUI (org.gephi.io.importer.spi.ImporterWizardUI)1 WizardImporter (org.gephi.io.importer.spi.WizardImporter)1 WizardImporterBuilder (org.gephi.io.importer.spi.WizardImporterBuilder)1 NotifyDescriptor (org.openide.NotifyDescriptor)1 WizardDescriptor (org.openide.WizardDescriptor)1