Search in sources :

Example 1 with LongTaskExecutor

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);
    }
}
Also used : DialogDescriptor(org.openide.DialogDescriptor) LongTaskExecutor(org.gephi.utils.longtask.api.LongTaskExecutor) Workspace(org.gephi.project.api.Workspace)

Example 2 with LongTaskExecutor

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);
    }
}
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 3 with LongTaskExecutor

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

Aggregations

LongTaskExecutor (org.gephi.utils.longtask.api.LongTaskExecutor)3 Workspace (org.gephi.project.api.Workspace)1 DynamicStatistics (org.gephi.statistics.spi.DynamicStatistics)1 StatisticsBuilder (org.gephi.statistics.spi.StatisticsBuilder)1 LongTask (org.gephi.utils.longtask.spi.LongTask)1 DialogDescriptor (org.openide.DialogDescriptor)1