/** * Execute the given task at some time in the future. * * @param <T> the return type for the task * @param task the task. * @return a worker that can be used to check the state of the task and * receive the result of it. */ public <T> Worker<T> submit(final Task<T> task) { return submit(ConcurrentUtils.createService(task)); }
/** * Execute the given callable at some time in the future. * * @param <T> the return type for the worker * @param callable the callable. If a <code>DataFxCallable</code> is used * here a <code>TaskStateHandler</code> will be injected. * @return a worker that can be used to check the state of the callable and * receive the result of it. */ public <T> Worker<T> submit(final Callable<T> callable) { return submit(ConcurrentUtils.createService(callable)); }
/** * Execute the given runnable at some time in the future. * * @param runnable the runnable. If a <code>DataFxRunnable</code> is used * here a <code>TaskStateHandler</code> will be injected. * @return a worker that can be used to check the state of the runnable */ public Worker<Void> submit(final Runnable runnable) { return submit(ConcurrentUtils.createService(runnable)); }
public static DataFxService<Void> createService(Runnable runnable) { return createService(new RunnableBasedDataFxTask(runnable)); }
public static <T> DataFxService<T> createService(Callable<T> callable) { return createService(new CallableBasedDataFxTask<T>(callable)); }
return ConcurrentUtils.executeService(executor, ConcurrentUtils.createService(runner));
private Worker<List<CrudObjectProperty<S, T>>> innerReload(Callable<List<S>> supplier) { return ConcurrentUtils.executeService(executor, ConcurrentUtils.createService(() -> { try { List<CrudObjectProperty<S, T>> newProperties = FXCollections.observableArrayList(); List<S> dataList = supplier.call(); for (S data : dataList) { newProperties.add(new CrudObjectProperty<S, T>(data, CrudListProperty.this, crudService, executor)); } ConcurrentUtils.runAndWait(() -> setAll(newProperties)); return newProperties; } catch (Exception e) { throw new RuntimeException("TODO", e); } })); }
public Worker<S> save() { return ConcurrentUtils.executeService(executor, ConcurrentUtils.createService(() -> { try { S updatedData = crudService.save(get()); ConcurrentUtils.runAndWait(() -> set(updatedData)); return updatedData; } catch (Exception e) { throw new RuntimeException("TODO", e); } })); }
public Worker<Void> delete() { return ConcurrentUtils.executeService(executor, ConcurrentUtils.createService(() -> { try { crudService.delete(get()); ConcurrentUtils.runAndWait(() -> { set(null); if (listProperty != null) { listProperty.remove(this); } }); } catch (Exception e) { throw new RuntimeException("TODO", e); } })); }
public Worker<S> update() { return ConcurrentUtils.executeService(executor, ConcurrentUtils.createService(() -> { try { T id = ConcurrentUtils.runCallableAndWait(() -> get().getId()); S updatedData = crudService.getById(id); ConcurrentUtils.runAndWait(() -> set(updatedData)); return updatedData; } catch (Exception e) { throw new RuntimeException("TODO", e); } })); }