Search in sources :

Example 1 with Processor

use of org.gephi.io.processor.spi.Processor in project gephi by gephi.

the class DesktopImportControllerUI method finishImport.

private void finishImport(Container[] containers) {
    Report finalReport = new Report();
    for (Container container : containers) {
        if (container.verify()) {
            Report report = container.getReport();
            report.close();
            finalReport.append(report);
        } else {
        //TODO
        }
    }
    finalReport.close();
    //Report panel
    ReportPanel reportPanel = new ReportPanel();
    reportPanel.setData(finalReport, containers);
    DialogDescriptor dd = new DialogDescriptor(reportPanel, NbBundle.getMessage(DesktopImportControllerUI.class, "ReportPanel.title"));
    Object response = DialogDisplayer.getDefault().notify(dd);
    reportPanel.destroy();
    finalReport.clean();
    for (Container c : containers) {
        c.getReport().clean();
    }
    if (!response.equals(NotifyDescriptor.OK_OPTION)) {
        return;
    }
    final Processor processor = reportPanel.getProcessor();
    //Project
    Workspace workspace = null;
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    ProjectControllerUI pcui = Lookup.getDefault().lookup(ProjectControllerUI.class);
    if (pc.getCurrentProject() == null) {
        pcui.newProject();
        workspace = pc.getCurrentWorkspace();
    }
    //Process
    final ProcessorUI pui = getProcessorUI(processor);
    final ValidResult validResult = new ValidResult();
    if (pui != null) {
        try {
            final JPanel panel = pui.getPanel();
            if (panel != null) {
                SwingUtilities.invokeAndWait(new Runnable() {

                    @Override
                    public void run() {
                        String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.processor.ui.dialog.title");
                        pui.setup(processor);
                        final DialogDescriptor dd2 = new DialogDescriptor(panel, title);
                        if (panel instanceof ValidationPanel) {
                            ValidationPanel vp = (ValidationPanel) panel;
                            vp.addChangeListener(new ChangeListener() {

                                @Override
                                public void stateChanged(ChangeEvent e) {
                                    dd2.setValid(!((ValidationPanel) e.getSource()).isProblem());
                                }
                            });
                            dd2.setValid(!vp.isProblem());
                        }
                        Object result = DialogDisplayer.getDefault().notify(dd2);
                        if (result.equals(NotifyDescriptor.CANCEL_OPTION) || result.equals(NotifyDescriptor.CLOSED_OPTION)) {
                            validResult.setResult(false);
                        } else {
                            //true
                            pui.unsetup();
                            validResult.setResult(true);
                        }
                    }
                });
            }
        } catch (InterruptedException ex) {
            Exceptions.printStackTrace(ex);
        } catch (InvocationTargetException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    if (validResult.isResult()) {
        controller.process(containers, processor, workspace);
        //StatusLine notify
        StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.status.multiImportSuccess", containers.length));
    }
}
Also used : JPanel(javax.swing.JPanel) Processor(org.gephi.io.processor.spi.Processor) Report(org.gephi.io.importer.api.Report) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel) ProjectController(org.gephi.project.api.ProjectController) ProcessorUI(org.gephi.io.processor.spi.ProcessorUI) InvocationTargetException(java.lang.reflect.InvocationTargetException) Container(org.gephi.io.importer.api.Container) ChangeEvent(javax.swing.event.ChangeEvent) DialogDescriptor(org.openide.DialogDescriptor) FileObject(org.openide.filesystems.FileObject) ChangeListener(javax.swing.event.ChangeListener) Workspace(org.gephi.project.api.Workspace) ProjectControllerUI(org.gephi.desktop.project.api.ProjectControllerUI)

Example 2 with Processor

use of org.gephi.io.processor.spi.Processor in project gephi by gephi.

the class ReportPanel method initProcessors.

private void initProcessors() {
    int i = 0;
    for (Processor processor : Lookup.getDefault().lookupAll(Processor.class)) {
        JRadioButton radio = new JRadioButton(processor.getDisplayName());
        radio.putClientProperty(PROCESSOR_KEY, processor);
        processorGroup.add(radio);
    }
}
Also used : Processor(org.gephi.io.processor.spi.Processor) JRadioButton(javax.swing.JRadioButton)

Example 3 with Processor

use of org.gephi.io.processor.spi.Processor in project gephi by gephi.

the class ImportControllerImpl method process.

@Override
public void process(Container container) {
    Processor processor = Lookup.getDefault().lookup(Processor.class);
    if (processor == null) {
        throw new RuntimeException("Impossible to find Default Processor");
    }
    process(container, processor, null);
}
Also used : Processor(org.gephi.io.processor.spi.Processor)

Aggregations

Processor (org.gephi.io.processor.spi.Processor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 ChangeEvent (javax.swing.event.ChangeEvent)1 ChangeListener (javax.swing.event.ChangeListener)1 ProjectControllerUI (org.gephi.desktop.project.api.ProjectControllerUI)1 Container (org.gephi.io.importer.api.Container)1 Report (org.gephi.io.importer.api.Report)1 ProcessorUI (org.gephi.io.processor.spi.ProcessorUI)1 ProjectController (org.gephi.project.api.ProjectController)1 Workspace (org.gephi.project.api.Workspace)1 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)1 DialogDescriptor (org.openide.DialogDescriptor)1 FileObject (org.openide.filesystems.FileObject)1