private static void onUncaughtException(Thread thread, Throwable throwable) { if (!ExceptionHandler.isLogException()) { LOGGER.log(Level.SEVERE, "Uncaught throwable in " + thread.getName(), throwable); } ExceptionHandler.getDefaultInstance().setException(throwable); }
public static synchronized ExceptionHandler getDefaultInstance() { if (defaultInstance == null) { defaultInstance = new ExceptionHandler(); setExceptionLogging(DataFXConfiguration.getInstance().isExceptionLoggingActive()); } return defaultInstance; }
public static void setExceptionLogging(boolean log) { if (log) { getDefaultInstance().exceptionProperty().addListener(getLoggerListener()); } else { getDefaultInstance().exceptionProperty().removeListener(getLoggerListener()); } logException = log; }
private void handleActionWithExceptionHandler(String id) { try { handle(id); } catch (VetoException | FlowException e) { getExceptionHandler().setException(e); } }
public FlowHandler(Flow flow, ViewFlowContext flowContext, ViewConfiguration viewConfiguration) { this(flow, flowContext, viewConfiguration, ExceptionHandler.getDefaultInstance()); }
public Throwable getException() { return exceptionProperty().get(); }
/** * Execute the given service at some time in the future. * * @param <T> The return type for the service * @param service the service. * @return a worker that can be used to check the state of the service and * receive the result of it. */ public <T> Worker<T> submit(Service<T> service) { service.setExecutor(executor); currentServices.add(service); if(exceptionHandler != null) { exceptionHandler.observeWorker(service); } service.start(); return service; }
private void handleBackActionWithExceptionHandler() { try { navigateBack(); } catch (VetoException | FlowException e) { getExceptionHandler().setException(e); } } }
public ObservableExecutor(Executor executor) { this(executor, ExceptionHandler.getDefaultInstance()); }
public void setException(Throwable exception) { if(Platform.isFxApplicationThread()) { exceptionProperty().set(exception); } else { try { ConcurrentUtils.runAndWait(() -> exceptionProperty().set(exception)); } catch (InterruptedException | ExecutionException e) { LOGGER.log(Level.SEVERE, "Can't handle exception in JavaFX Application Thread!", e); LOGGER.log(Level.SEVERE, "Initial exception: ", exception); } } }
public <T> void observeWorker(Worker<T> worker) { worker.exceptionProperty().addListener((ob, ol, e) -> setException(e)); }
/** * This methods creates a tab that contains the given view. * By doing so the metadata of the view will be bound to the tab properties. * So the text and icon of the tab can be changed by the view. * * @param context the context of the view. This includes the view and its controller instance * so that all needed informations are part of the context */ public <T> Tab createTab(ViewContext<T> context) { return createTab(context, ExceptionHandler.getDefaultInstance()); }
c.accept(event); } catch (Exception e) { exceptionHandler.setException(e); c.accept(event); } catch (Exception e) { exceptionHandler.setException(e); exceptionHandler.setException(e); } catch (ExecutionException e) { exceptionHandler.setException(e);
public static <T> List<TableColumn<T, ?>> createColumns(Class<T> entityType) { return createColumns(entityType, ExceptionHandler.getDefaultInstance()); }
public void attachLinkEventHandler(MenuItem menuItem, Class<?> controllerClass) { handler.attachAction(menuItem, () -> { try { navigate(controllerClass); } catch (Exception e) { getExceptionHandler().setException(e); } }); }
/** * default constructor */ private EventSystem() { consumers = FXCollections.observableHashMap(); asyncConsumers = FXCollections.observableHashMap(); exceptionHandler = ExceptionHandler.getDefaultInstance(); executor = ObservableExecutor.getDefaultInstance(); }
public void attachLinkEventHandler(Node node, Class<?> controllerClass) { handler.attachAction(node, () -> { try { navigate(controllerClass); } catch (Exception e) { getExceptionHandler().setException(e); } }); }
public static <T> List<TableColumn<T, ?>> createColumns(Class<T> entityType, ExceptionHandler exceptionHandler) { List<TableColumn<T, ?>> columns = new ArrayList<>(); for (Field field : entityType.getDeclaredFields()) { ViewColumn columnAnnotation = field.getAnnotation(ViewColumn.class); if (columnAnnotation != null) { TableColumn<T, ?> column = new TableColumn<>(); column.setText(columnAnnotation.value()); column.setEditable(columnAnnotation.editable()); column.setSortable(columnAnnotation.sortable()); column.setResizable(columnAnnotation.resizeable()); column.setCellValueFactory(e -> { try { return new SimpleObjectProperty(DataFXUtils.getPrivileged(field, e.getValue())); } catch (Exception exception) { exceptionHandler.setException(exception); return null; } }); columns.add(column); } } return columns; } }
/** * This methods creates a tab that contains the given view. * By doing so the metadata of the view will be bound to the tab properties. * So the text and icon of the tab can be changed by the view. * * @param context the context of the view. This includes the view and its controller instance * so that all needed informations are part of the context * @param exceptionHandler the exception handle for the view. This handler will handle all exceptions that will be thrown in the DataFX container context */ public <T> Tab createTab(ViewContext<T> context, ExceptionHandler exceptionHandler) { Tab tab = new Tab(); tab.textProperty().bind(context.getMetadata().titleProperty()); tab.graphicProperty().bind(context.getMetadata().graphicsProperty()); tab.setOnClosed(e -> { try { context.destroy(); } catch (Exception exception) { exceptionHandler.setException(exception); } }); tab.setContent(context.getRootNode()); return tab; }
public <T extends Node> Tab startInTab(FlowContainer<T> container) throws FlowException { Tab tab = new Tab(); getCurrentViewMetadata().addListener((e) -> { tab.textProperty().unbind(); tab.graphicProperty().unbind(); tab.textProperty().bind(getCurrentViewMetadata().get().titleProperty()); tab.graphicProperty().bind(getCurrentViewMetadata().get().graphicsProperty()); }); tab.setOnClosed(e -> { try { destroy(); } catch (Exception exception) { exceptionHandler.setException(exception); } }); tab.setContent(start(container)); return tab; }