Search in sources :

Example 1 with ImporterWizardUI

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

the class WizardVisualPanel1 method reloadDescription.

private void reloadDescription() {
    String description = "";
    if (emptyList()) {
        description = NbBundle.getMessage(WizardPanel1.class, "ImportWizard.description_no_plugin_importers_installed");
    } else {
        String category = categoryList.getSelectedValue().toString();
        String wizard = wizardList.getSelectedValue().toString();
        for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
            if (category.equals(wizardUi.getCategory()) && wizard.equals(wizardUi.getDisplayName())) {
                description = wizardUi.getDescription();
                break;
            }
        }
    }
    descriptionArea.setText(description);
}
Also used : ImporterWizardUI(org.gephi.io.importer.spi.ImporterWizardUI)

Example 2 with ImporterWizardUI

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

the class WizardVisualPanel1 method reloadSubType.

private ListModel reloadSubType() {
    subTypeModel.clear();
    if (categoryList.getSelectedValue() == null) {
        return subTypeModel;
    }
    String category = categoryList.getSelectedValue().toString();
    for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
        if (category.equals(wizardUi.getCategory())) {
            subTypeModel.addElement(wizardUi.getDisplayName());
            descriptionArea.setText(wizardUi.getDescription());
        }
    }
    return subTypeModel;
}
Also used : ImporterWizardUI(org.gephi.io.importer.spi.ImporterWizardUI)

Example 3 with ImporterWizardUI

use of org.gephi.io.importer.spi.ImporterWizardUI 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)

Example 4 with ImporterWizardUI

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

the class WizardIterator method nextPanel.

@Override
public void nextPanel() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    // change panel if the current is the  first panel
    if (index == 0) {
        for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
            WizardVisualPanel1 visual1 = ((WizardVisualPanel1) current().getComponent());
            if (visual1.getCurrentCategory().equals(wizardUi.getCategory()) && visual1.getCurrentWizard().equals(wizardUi.getDisplayName())) {
                WizardDescriptor.Panel[] wizardPanels = wizardUi.getPanels();
                WizardDescriptor.Panel tempFirstPanel = panels[0];
                panels = new WizardDescriptor.Panel[wizardPanels.length + 1];
                panels[0] = tempFirstPanel;
                for (int i = 0; i < wizardPanels.length; i++) {
                    panels[i + 1] = wizardPanels[i];
                    wizardUi.setup(wizardPanels[i]);
                }
                currentWizardUI = wizardUi;
            }
        }
        // 
        repaintLeftComponent();
    }
    index++;
}
Also used : WizardDescriptor(org.openide.WizardDescriptor) ImporterWizardUI(org.gephi.io.importer.spi.ImporterWizardUI) NoSuchElementException(java.util.NoSuchElementException)

Example 5 with ImporterWizardUI

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

the class DesktopImportControllerUI method importWizard.

@Override
public void importWizard(final WizardImporter importer) {
    try {
        if (importer == null) {
            NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.error_no_matching_db_importer"), NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notify(msg);
            return;
        }
        String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.wizardSource", "");
        ImporterUI ui = controller.getUI(importer);
        if (ui != null) {
            String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.wizard.ui.dialog.title", ui.getDisplayName());
            JPanel panel = ui.getPanel();
            ui.setup(new WizardImporter[] { importer });
            final DialogDescriptor dd = new DialogDescriptor(panel, title);
            if (panel instanceof ValidationPanel) {
                ValidationPanel vp = (ValidationPanel) panel;
                vp.addChangeListener(new ChangeListener() {

                    @Override
                    public void stateChanged(ChangeEvent e) {
                        dd.setValid(!((ValidationPanel) e.getSource()).isProblem());
                    }
                });
            }
            Object result = DialogDisplayer.getDefault().notify(dd);
            if (result.equals(NotifyDescriptor.CANCEL_OPTION) || result.equals(NotifyDescriptor.CLOSED_OPTION)) {
                ui.unsetup(false);
                return;
            }
            ui.unsetup(true);
            containerSource = ui.getDisplayName();
        }
        ImporterWizardUI wizardUI = controller.getWizardUI(importer);
        if (wizardUI != null) {
            containerSource = wizardUI.getCategory() + ":" + wizardUI.getDisplayName();
        }
        LongTask task = null;
        if (importer instanceof LongTask) {
            task = (LongTask) importer;
        }
        // Execute task
        final String source = containerSource;
        String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource);
        executor.execute(task, new Runnable() {

            @Override
            public void run() {
                try {
                    Container container = controller.importWizard(importer);
                    if (container != null) {
                        container.setSource(source);
                        finishImport(container);
                    }
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }, taskName, errorHandler);
    } catch (Exception ex) {
        Logger.getLogger("").log(Level.WARNING, "", ex);
    }
}
Also used : ImporterUI(org.gephi.io.importer.spi.ImporterUI) JPanel(javax.swing.JPanel) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel) ImporterWizardUI(org.gephi.io.importer.spi.ImporterWizardUI) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) NotifyDescriptor(org.openide.NotifyDescriptor) Container(org.gephi.io.importer.api.Container) ChangeEvent(javax.swing.event.ChangeEvent) LongTask(org.gephi.utils.longtask.spi.LongTask) DialogDescriptor(org.openide.DialogDescriptor) ChangeListener(javax.swing.event.ChangeListener) FileObject(org.openide.filesystems.FileObject)

Aggregations

ImporterWizardUI (org.gephi.io.importer.spi.ImporterWizardUI)5 NotifyDescriptor (org.openide.NotifyDescriptor)2 WizardDescriptor (org.openide.WizardDescriptor)2 Dialog (java.awt.Dialog)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MessageFormat (java.text.MessageFormat)1 NoSuchElementException (java.util.NoSuchElementException)1 JPanel (javax.swing.JPanel)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 ImportControllerUI (org.gephi.desktop.importer.api.ImportControllerUI)1 Container (org.gephi.io.importer.api.Container)1 ImporterUI (org.gephi.io.importer.spi.ImporterUI)1 WizardImporter (org.gephi.io.importer.spi.WizardImporter)1 WizardImporterBuilder (org.gephi.io.importer.spi.WizardImporterBuilder)1 LongTask (org.gephi.utils.longtask.spi.LongTask)1 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)1 DialogDescriptor (org.openide.DialogDescriptor)1 FileObject (org.openide.filesystems.FileObject)1