@@ -0,0 +1,3246 @@
+/******************************************************************************%0A *                                                                            *%0A *                    Copyright 2019 Subterranean Security                    *%0A *                                                                            *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);           *%0A *  you may not use this file except in compliance with the License.          *%0A *  You may obtain a copy of the License at                                   *%0A *                                                                            *%0A *      http://www.apache.org/licenses/LICENSE-2.0                            *%0A *                                                                            *%0A *  Unless required by applicable law or agreed to in writing, software       *%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,         *%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  *%0A *  See the License for the specific language governing permissions and       *%0A *  limitations under the License.                                            *%0A *                                                                            *%0A *****************************************************************************/%0Apackage com.sandpolis.viewer.jfx.common;%0A%0Aimport java.io.IOException;%0Aimport java.util.Arrays;%0Aimport java.util.Objects;%0A%0Aimport com.google.common.eventbus.EventBus;%0Aimport com.sandpolis.viewer.jfx.common.controller.AbstractController;%0A%0Aimport javafx.fxml.FXMLLoader;%0A%0A/**%0A * Miscellaneous JavaFX utilities.%0A * %0A * @author cilki%0A * @since 5.0.0%0A */%0Apublic final class FxUtil %7B%0A%0A%09/**%0A%09 * Load a FXML resource.%0A%09 * %0A%09 * @param location The absolute location of a FXML resource%0A%09 * @param parent   The parent controller%0A%09 * @return The object hierarchy from the FXML%0A%09 * @throws IOException If the requested resource is not found%0A%09 */%0A%09public static %3CE%3E E load(String location, AbstractController parent) throws IOException %7B%0A%09%09Objects.requireNonNull(location);%0A%09%09Objects.requireNonNull(parent);%0A%0A%09%09FXMLLoader loader = new FXMLLoader(FxUtil.class.getResource(location));%0A%09%09E node = loader.load();%0A%0A%09%09AbstractController controller = loader.getController();%0A%09%09if (controller != null)%0A%09%09%09if (parent.getBus() == null)%0A%09%09%09%09parent.register(controller);%0A%09%09%09else%0A%09%09%09%09controller.setBus(parent.getBus());%0A%0A%09%09return node;%0A%09%7D%0A%0A%09/**%0A%09 * Load a root FXML resource.%0A%09 * %0A%09 * @param location   The absolute location of a FXML resource%0A%09 * @param parameters A list of parameters that will be posted to the%0A%09 *                   controller's %7B@link EventBus%7D%0A%09 * @return The object hierarchy from the FXML%0A%09 * @throws IOException If the requested resource is not found%0A%09 */%0A%09public static %3CE%3E E loadRoot(String location, Object... parameters) throws IOException %7B%0A%09%09Objects.requireNonNull(location);%0A%0A%09%09FXMLLoader loader = new FXMLLoader(FxUtil.class.getResource(location));%0A%09%09E node = loader.load();%0A%0A%09%09AbstractController controller = loader.getController();%0A%09%09controller.setBus(new EventBus());%0A%0A%09%09Arrays.stream(parameters).forEach(controller.getBus()::post);%0A%09%09return node;%0A%09%7D%0A%0A%09private FxUtil() %7B%0A%09%7D%0A%0A%7D%0A

Add FxUtil