private void activeController(final ContentController subController, final boolean animated) { if (this.activeController == subController) { return; } final int from = this.controllers.indexOf(this.activeController); final int to = this.controllers.indexOf(subController); final ContentController oldController = this.activeController; subController.getRootNode().setVisible(true); if (oldController != null) { oldController.getRootNode().setVisible(false); oldController.onDeactivate(); oldController.getNavigationButton().getStyleClass().remove("selected"); } this.activeController = subController; this.activeController.getNavigationButton().getStyleClass().add("selected"); final int direction = from < to ? -1 : 1; if (animated && oldController != null) { animateController(subController, oldController, direction); } this.activeController.onActivate(); }
private void animateController( final ContentController subController, final ContentController oldController, final int direction) { if (oldController != null) { oldController.getRootNode().setVisible(false); oldController.onDeactivate(); oldController.getNavigationButton().getStyleClass().remove("selected"); } this.activeController = subController; this.activeController.getNavigationButton().getStyleClass().add("selected"); }
private ContentController loadSubController(final String viewPath) { try { ContentController controller; Result loadResult; loadResult = this.fxmlLoader.load(OfficeController.class.getResource(viewPath)); controller = loadResult.getController(); controller.setControllerConstrains(); // controller.getRootNode().getStyleClass().add("bodyHBox"); return controller; } catch (final IOException e) { e.printStackTrace(); return null; } }
private void loadSubControllers() throws IOException { for (final String key : this.optionsViews.keySet()) { final ContentController controller = loadSubController(this.optionsViews.get(key)); if (controller != null) { this.controllers.add(controller); this.component.getChildren().add(controller.getRootNode()); controller.getRootNode().setVisible(false); controller.setName(key); //// final Button buttonNav = new Button(key); buttonNav.getStyleClass().add("nav-button"); buttonNav.getStyleClass().add("xine-button"); buttonNav.setPrefHeight(49); buttonNav.setOnAction( e -> { activeController(controller); }); //// controller.setNavigationButton(buttonNav); this.navItems.getChildren().add(controller.getNavigationButton()); // this.component.getChildren().add(controller.getRootNode()); } } }
public OfficeController() { super.setName("Office"); }