Search in sources :

Example 1 with ProjectController

use of org.gephi.project.api.ProjectController in project gephi by gephi.

the class AppendProcessor method process.

@Override
public void process() {
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    if (containers.length > 1) {
        throw new RuntimeException("This processor can only handle single containers");
    }
    ContainerUnloader container = containers[0];
    //Workspace
    if (workspace == null) {
        workspace = pc.getCurrentWorkspace();
        if (workspace == null) {
            //Append mode but no workspace
            workspace = pc.newWorkspace(pc.getCurrentProject());
            pc.openWorkspace(workspace);
            processConfiguration(container, workspace);
        }
    }
    if (container.getSource() != null) {
        pc.setSource(workspace, container.getSource());
    }
    process(container, workspace);
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Example 2 with ProjectController

use of org.gephi.project.api.ProjectController in project gephi by gephi.

the class MergeProcessor method process.

@Override
public void process() {
    if (containers.length <= 1) {
        throw new RuntimeException("This processor can only handle multiple containers");
    }
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    //Workspace
    if (workspace == null) {
        workspace = pc.newWorkspace(pc.getCurrentProject());
        pc.openWorkspace(workspace);
    }
    processConfiguration(containers[0], workspace);
    for (ContainerUnloader container : containers) {
        process(container, workspace);
    }
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Example 3 with ProjectController

use of org.gephi.project.api.ProjectController in project gephi by gephi.

the class MultiProcessor method process.

@Override
public void process() {
    if (containers.length <= 1) {
        throw new RuntimeException("This processor can only handle multiple containers");
    }
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    for (ContainerUnloader container : containers) {
        if (workspace != null) {
            pc.openWorkspace(workspace);
        } else {
            workspace = pc.newWorkspace(pc.getCurrentProject());
        }
        processConfiguration(container, workspace);
        process(container, workspace);
        workspace = null;
    }
    //Clean
    workspace = null;
    graphModel = null;
    containers = null;
    progressTicket = null;
}
Also used : ContainerUnloader(org.gephi.io.importer.api.ContainerUnloader) ProjectController(org.gephi.project.api.ProjectController)

Example 4 with ProjectController

use of org.gephi.project.api.ProjectController 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 5 with ProjectController

use of org.gephi.project.api.ProjectController in project gephi by gephi.

the class DesktopGeneratorController method finishGenerate.

private void finishGenerate(Container container) {
    ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
    ProjectControllerUI pcui = Lookup.getDefault().lookup(ProjectControllerUI.class);
    Workspace workspace;
    if (pc.getCurrentProject() == null) {
        pcui.newProject();
        workspace = pc.getCurrentWorkspace();
    } else {
        workspace = pc.newWorkspace(pc.getCurrentProject());
        pc.openWorkspace(workspace);
    }
    if (container.getSource() != null) {
        pc.setSource(workspace, container.getSource());
    }
    container.closeLoader();
    DefaultProcessor defaultProcessor = new DefaultProcessor();
    defaultProcessor.setContainers(new ContainerUnloader[] { container.getUnloader() });
    defaultProcessor.setWorkspace(workspace);
    defaultProcessor.process();
}
Also used : DefaultProcessor(org.gephi.io.processor.plugin.DefaultProcessor) ProjectController(org.gephi.project.api.ProjectController) ProjectControllerUI(org.gephi.desktop.project.api.ProjectControllerUI) Workspace(org.gephi.project.api.Workspace)

Aggregations

ProjectController (org.gephi.project.api.ProjectController)22 Workspace (org.gephi.project.api.Workspace)11 ProjectControllerUI (org.gephi.desktop.project.api.ProjectControllerUI)4 ContainerUnloader (org.gephi.io.importer.api.ContainerUnloader)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)2 JPanel (javax.swing.JPanel)2 GraphController (org.gephi.graph.api.GraphController)2 GraphModel (org.gephi.graph.api.GraphModel)2 WorkspaceInformation (org.gephi.project.api.WorkspaceInformation)2 WorkspaceListener (org.gephi.project.api.WorkspaceListener)2 WorkspaceProvider (org.gephi.project.api.WorkspaceProvider)2 DialogDescriptor (org.openide.DialogDescriptor)2 BorderLayout (java.awt.BorderLayout)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1