Search in sources :

Example 16 with LongTask

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);
    }
}
Also used : LongTask(org.gephi.utils.longtask.spi.LongTask) DynamicStatistics(org.gephi.statistics.spi.DynamicStatistics) LongTaskExecutor(org.gephi.utils.longtask.api.LongTaskExecutor) StatisticsBuilder(org.gephi.statistics.spi.StatisticsBuilder)

Example 17 with LongTask

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());
}
Also used : MostRecentFiles(org.gephi.desktop.mrufiles.api.MostRecentFiles) LongTask(org.gephi.utils.longtask.spi.LongTask)

Example 18 with LongTask

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();
    }
}
Also used : LongTask(org.gephi.utils.longtask.spi.LongTask)

Aggregations

LongTask (org.gephi.utils.longtask.spi.LongTask)18 JPanel (javax.swing.JPanel)7 ChangeEvent (javax.swing.event.ChangeEvent)7 ChangeListener (javax.swing.event.ChangeListener)7 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)7 DialogDescriptor (org.openide.DialogDescriptor)7 NotifyDescriptor (org.openide.NotifyDescriptor)7 IOException (java.io.IOException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 Container (org.gephi.io.importer.api.Container)6 ImporterUI (org.gephi.io.importer.spi.ImporterUI)6 FileObject (org.openide.filesystems.FileObject)6 MostRecentFiles (org.gephi.desktop.mrufiles.api.MostRecentFiles)4 FileImporter (org.gephi.io.importer.spi.FileImporter)4 PreviewController (org.gephi.preview.api.PreviewController)3 StatisticsController (org.gephi.statistics.api.StatisticsController)3 LongTaskListener (org.gephi.utils.longtask.api.LongTaskListener)3 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 GZIPInputStream (java.util.zip.GZIPInputStream)2