Beispiel #1
0
 private void devicesListValueChanged(
     javax.swing.event.ListSelectionEvent evt) { // GEN-FIRST:event_devicesListValueChanged
   if (devicesList.getSelectedIndex() == -1) {
     cardLayout.show(dummyPhonePanel, blank);
   } else {
     ManagedDevice device = androidSMNPManager.getManagedDevice(devicesList.getSelectedIndex());
     cardLayout.show(dummyPhonePanel, device.getIp());
   }
 } // GEN-LAST:event_devicesListValueChanged
Beispiel #2
0
  private void editDeviceButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_editDeviceButtonActionPerformed
    int selectedIndex = devicesList.getSelectedIndex();
    String ip = androidSMNPManager.getManagedDevice(selectedIndex).getIp();

    do {
      ip =
          (String)
              JOptionPane.showInputDialog(
                  this,
                  "Enter the IP address of the device:",
                  "Edit Device",
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  ip);

      if (ip != null) {
        if (ManagedDevice.isIpValid(ip)) {
          if (androidSMNPManager.hasDevice(ip)) {
            JOptionPane.showMessageDialog(this, "There is already one device with this IP!");
          } else {
            androidSMNPManager.removeManagedDevice(selectedIndex);
            ManagedDevice device = new ManagedDevice(ip);
            androidSMNPManager.addManagedDevice(device, selectedIndex);
            return;
          }
        } else {
          JOptionPane.showMessageDialog(
              this,
              "Invalid IP Address!\nMake sure the IP is in the format [0..255].[0..255].[0..255].[0..255]");
        }
      }
    } while (ip != null);
  } // GEN-LAST:event_editDeviceButtonActionPerformed
Beispiel #3
0
  private void addDeviceButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_addDeviceButtonActionPerformed
    String ip = "___.___.___.___";

    do {
      ip =
          (String)
              JOptionPane.showInputDialog(
                  this,
                  "Enter the IP address of the device:",
                  "Add Device",
                  JOptionPane.PLAIN_MESSAGE,
                  null,
                  null,
                  ip);

      if (ip != null) {
        if (ManagedDevice.isIpValid(ip)) {
          if (androidSMNPManager.hasDevice(ip)) {
            JOptionPane.showMessageDialog(this, "There is already one device with this IP!");
          } else {
            addDevice(ip);
            break;
          }
        } else {
          JOptionPane.showMessageDialog(
              this,
              "Invalid IP Address!\nMake sure the IP is in the format [0..255].[0..255].[0..255].[0..255]");
        }
      }
    } while (ip != null);
  } // GEN-LAST:event_addDeviceButtonActionPerformed
Beispiel #4
0
  private void discoverButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_discoverButtonActionPerformed
    if (ManagedDevice.isIpValid(rangeBeginTextField.getText())) {
      if (ManagedDevice.isIpValid(rangeEndTextField.getText())) {
        int[] begin = new int[4];
        int[] end = new int[4];

        String[] result = rangeBeginTextField.getText().split("\\.");
        for (int i = 0; i < 4; i++) {
          begin[i] = Integer.parseInt(result[i]);
        }

        result = rangeEndTextField.getText().split("\\.");
        for (int i = 0; i < 4; i++) {
          end[i] = Integer.parseInt(result[i]);
        }

        if (begin[0] != end[0] || begin[1] != end[1] || begin[2] != end[2]) {
          JOptionPane.showMessageDialog(this, "Range too big!");
          rangeEndTextField.requestFocus();
        } else {
          if (begin[3] > end[3]) {
            int temp = begin[3];
            begin[3] = end[3];
            end[3] = temp;
          }
          SNMPMessenger.discoverDevices(begin, end, this);
        }
      } else {
        JOptionPane.showMessageDialog(this, "Invalid IP address!");
        rangeEndTextField.requestFocus();
      }
    } else {
      JOptionPane.showMessageDialog(this, "Invalid IP address!");
      rangeBeginTextField.requestFocus();
    }
  } // GEN-LAST:event_discoverButtonActionPerformed
Beispiel #5
0
 public void addPhonePanel(ManagedDevice device, Object constraints) {
   dummyPhonePanel.add(device.getPhonePanel(), constraints);
   devicesList.setSelectedValue(device, true);
   device.updateEverything();
 }