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