Пример #1
0
  public void onLocalDeviceComplete(@Observes @Phase.Complete LocalDeviceDiscovery discovery) {
    LocalDevice device = discovery.getDevice();

    String[] labels =
        new String[] {
          device.getDetails().getFriendlyName(),
          device.getDisplayString(),
          "(LOCAL) " + device.getType().getDisplayString()
        };

    final DeviceItem deviceItem = new DeviceItem(device, labels);

    Icon usableIcon = findUsableIcon(device);
    if (usableIcon != null) {
      ImageIcon imageIcon = new ImageIcon(usableIcon.getData());
      deviceItem.setIcon(imageIcon);
    } else {
      deviceItem.setIcon(getUnknownDeviceIcon(deviceItem.getLabel()[0]));
    }

    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            view.addDeviceItem(deviceItem);
          }
        });
  }
Пример #2
0
 public void onLocalDeviceRemoved(@Observes @Phase.Byebye LocalDeviceDiscovery discovery) {
   LocalDevice device = discovery.getDevice();
   final DeviceItem deviceItem = new DeviceItem(device, device.getDisplayString());
   SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {
           view.removeDeviceItem(deviceItem);
         }
       });
 }