use of org.gephi.utils.longtask.api.LongTaskExecutor in project gephi-plugins-bootcamp by gephi.
the class SQLiteDatabaseExporterUI method action.
@Override
public void action() {
//Create exporter
final SQLiteDatabaseExporter exporter = new SQLiteDatabaseExporter();
//Create the settings panel
SQLiteDatabaseSettingsPanel settingPanel = new SQLiteDatabaseSettingsPanel();
settingPanel.setup(exporter);
final DialogDescriptor dd = new DialogDescriptor(settingPanel, "SQLite Database Export");
Object result = DialogDisplayer.getDefault().notify(dd);
if (result == NotifyDescriptor.OK_OPTION) {
//This line will write the file path from the panel to the exporter's <code>setPath()<code> method.
settingPanel.unsetup(true);
//Create a new executor and execute
LongTaskExecutor executor = new LongTaskExecutor(true, "SQLite Exporter");
executor.setDefaultErrorHandler(errorHandler);
executor.execute(exporter, new Runnable() {
@Override
public void run() {
//Get the current workspace and set it to the exporter
Workspace currentWorkspace = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace();
exporter.setWorkspace(currentWorkspace);
//Execute export
cancelled = !exporter.execute();
//If not cancelled, write a status line message
if (!cancelled) {
StatusDisplayer.getDefault().setStatusText("Export to SQLite database completed");
}
}
});
} else {
settingPanel.unsetup(false);
}
}
use of org.gephi.utils.longtask.api.LongTaskExecutor in project gephi by gephi.
the class StatisticsControllerImpl method execute.
@Override
public void execute(final Statistics statistics, LongTaskListener listener) {
StatisticsBuilder builder = getBuilder(statistics.getClass());
LongTaskExecutor executor = new LongTaskExecutor(true, "Statistics " + builder.getName(), 10);
if (listener != null) {
executor.setLongTaskListener(listener);
}
if (statistics instanceof DynamicStatistics) {
final DynamicLongTask dynamicLongTask = new DynamicLongTask((DynamicStatistics) statistics);
executor.execute(dynamicLongTask, new Runnable() {
@Override
public void run() {
executeDynamic((DynamicStatistics) statistics, dynamicLongTask);
}
}, builder.getName(), null);
} else {
LongTask task = statistics instanceof LongTask ? (LongTask) statistics : null;
executor.execute(task, new Runnable() {
@Override
public void run() {
execute(statistics);
}
}, builder.getName(), null);
}
}
use of org.gephi.utils.longtask.api.LongTaskExecutor in project gephi-plugins-bootcamp by gephi.
the class UsingProgressAndCancelAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
LongTaskExecutor executor = new LongTaskExecutor(true);
LongTaskExample longTaskExample = new LongTaskExample();
executor.execute(longTaskExample, longTaskExample, "Task...", null);
}
Aggregations