コード例 #1
0
ファイル: ConnectionPanel.java プロジェクト: citojems/crw-cmu
  private void registryComboActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_registryComboActionPerformed
    synchronized (this) {
      String registryAddr = ((String) registryCombo.getSelectedItem()).trim();
      InetSocketAddress addr = CrwNetworkUtils.toInetSocketAddress(registryAddr);
      _vehicle.setRegistryService(addr);
      System.out.println("SET REGISTRY TO " + _vehicle.getRegistryService());

      // Remove old vehicle entries
      synchronized (_cachedVehicles) {
        for (Iterator<String> it = _cachedVehicles.iterator(); it.hasNext(); ) {
          String vehicle = it.next();
          if (!connectCombo.getSelectedItem().equals(vehicle)) {
            it.remove();
            connectCombo.removeItem(vehicle);
          }
        }
      }
    }
  } // GEN-LAST:event_registryComboActionPerformed
コード例 #2
0
ファイル: ConnectionPanel.java プロジェクト: citojems/crw-cmu
  private void connectComboActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_connectComboActionPerformed
    synchronized (this) {
      // Create a new proxy server that accesses the vehicle
      try {
        // Set vehicle to new address
        String addr = ((String) connectCombo.getSelectedItem()).split("-")[0].trim();
        _vehicle.setVehicleService(CrwNetworkUtils.toInetSocketAddress(addr));

        // Update listeners to new vehicle status
        fireConnectionListener(_vehicle);
        System.out.println("SET VEHICLE TO " + _vehicle.getVehicleService());

        // If vehicle is valid, store last used
        if (_vehicle.getVehicleService() != null) {
          Preferences p = Preferences.userRoot();
          p.put(LAST_URI_KEY, addr);
        }
      } catch (Exception ex) {
        System.err.println("Failed to open vehicle proxy: " + ex);
        return;
      }
    }
  } // GEN-LAST:event_connectComboActionPerformed
コード例 #3
0
ファイル: ConnectionPanel.java プロジェクト: citojems/crw-cmu
  private void autonomousBoxActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_autonomousBoxActionPerformed
    if (evt.getActionCommand().equals("toggle")) {
      final boolean value = !autonomousBox.isSelected();
      _vehicle.setAutonomous(
          value,
          new FunctionObserver<Void>() {

            public void completed(Void v) {
              autonomousBox.setSelected(value);
            }

            public void failed(FunctionError fe) {}
          });
    }
  } // GEN-LAST:event_autonomousBoxActionPerformed