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));
}
}
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);
}
}
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);
}
Aggregations