use of org.gephi.utils.longtask.spi.LongTask 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.spi.LongTask in project gephi by gephi.
the class ProjectControllerUIImpl method saveProject.
private void saveProject(Project project, File file) {
lockProjectActions();
final Runnable saveTask = controller.saveProject(project, file);
final String fileName = file.getName();
Runnable saveRunnable = new Runnable() {
@Override
public void run() {
saveTask.run();
//Status line
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(ProjectControllerUIImpl.class, "ProjectControllerUI.status.saved", fileName));
}
};
if (saveTask instanceof LongTask) {
longTaskExecutor.execute((LongTask) saveTask, saveRunnable);
} else {
longTaskExecutor.execute(null, saveRunnable);
}
//Save MRU
MostRecentFiles mostRecentFiles = Lookup.getDefault().lookup(MostRecentFiles.class);
mostRecentFiles.addFile(file.getAbsolutePath());
}
use of org.gephi.utils.longtask.spi.LongTask in project gephi by gephi.
the class StatisticsFrontEnd method cancel.
private void cancel() {
if (currentStatistics != null && currentStatistics instanceof LongTask) {
LongTask longTask = (LongTask) currentStatistics;
longTask.cancel();
}
}
Aggregations