Ejemplo n.º 1
0
  public void init() {
    this.connectionManager =
        new ConnectionManager(eventManager, statisticsManager, configurationManager);

    statisticsManager.loadStats();

    // Set up scene
    scene = getParentWindow().getScene();

    // Set up window events
    getParentWindow()
        .setOnCloseRequest(
            new EventHandler<WindowEvent>() {
              public void handle(WindowEvent t) {
                exit();
              }
            });
    scene
        .widthProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observableValue,
                  Number oldSceneWidth,
                  Number newSceneWidth) {
                if (!getStage().isMaximized()) {
                  setLastWidth((double) newSceneWidth);
                }
              }
            });
    scene
        .heightProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> observableValue,
                  Number oldSceneHeight,
                  Number newSceneHeight) {
                if (!getStage().isMaximized()) {
                  setLastHeight((double) newSceneHeight);
                }
              }
            });

    // Clear any test tabs
    stage.setTitle("mqtt-spy");

    controlPanelPaneController.setMainController(this);
    controlPanelPaneController.setConfigurationMananger(configurationManager);
    controlPanelPaneController.setApplication(application);
    controlPanelPaneController.setEventManager(eventManager);
    controlPanelPaneController.setConnectionManager(connectionManager);
    controlPanelPaneController.init();

    new Thread(new ConnectionStatsUpdater(connectionManager)).start();
  }
Ejemplo n.º 2
0
  @FXML
  public void exit() {
    // This is triggered by the user
    connectionManager.disconnectAll();

    statisticsManager.saveStats();

    configurationManager.saveUiProperties(
        getLastWidth(),
        getLastHeight(),
        stage.isMaximized(),
        selectedPerspective,
        resizeMessagePaneMenu.isSelected());

    System.exit(0);
  }