Exemplo n.º 1
0
  private void showEditConnectionsWindow(final boolean createNew) {
    if (editConnectionsController == null) {
      initialiseEditConnectionsWindow();
    }

    if (createNew) {
      editConnectionsController.newConnection();
    }

    editConnectionsController.updateSelected();
    editConnectionsStage.showAndWait();
    controlPanelPaneController.refreshConnectionsStatus();
  }
Exemplo n.º 2
0
  private void loadConfigurationFile(final File selectedFile) {
    logger.info("Loading configuration file from " + selectedFile.getAbsolutePath());

    if (configurationManager.loadConfiguration(selectedFile)) {
      clear();
      controlPanelPaneController.refreshConnectionsStatus();

      // Process the connection settings
      for (final ConfiguredConnectionDetails connection : configurationManager.getConnections()) {
        if (connection.isAutoOpen() != null && connection.isAutoOpen()) {
          try {
            connectionManager.openConnection(connection, this);
          } catch (ConfigurationException e) {
            // TODO: show warning dialog for invalid
            logger.error("Cannot open conection {}", connection.getName(), e);
          }
        }
      }
    }

    controlPanelPaneController.refreshConfigurationFileStatus();
  }
Exemplo n.º 3
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();
  }