Пример #1
0
  @Override
  public void onInvoke() {

    ActionInvocation actionInvocation = new ActionInvocation(action, view.getInputValues());

    // Starts background thread
    Workbench.Log.ACTION_INVOCATION.info("Executing action: " + action.getName());
    ActionCallback actionCallback =
        new ControlActionCallback(actionInvocation) {
          @Override
          protected void onSuccess(final ActionArgumentValue[] values) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    view.setCancelEnabled(false);
                    view.setOutputValues(values);
                  }
                });
          }

          @Override
          public void failure(
              ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    view.setCancelEnabled(false);
                  }
                });
            super.failure(invocation, operation, defaultMsg);
          }
        };
    actionExecutionFuture = controlPoint.execute(actionCallback);
    view.setCancelEnabled(true);
  }
Пример #2
0
  protected void updateConnectionInfo() {
    controlPoint.execute(
        new GetExternalIP(service) {
          @Override
          protected void success(final String externalIPAddress) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    view.setExternalIP(externalIPAddress);
                  }
                });
          }

          @Override
          public void failure(
              ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            Workbench.log(
                new LogMessage(
                    Level.INFO,
                    "WANIPConnection ControlPoint",
                    "Can't retrieve external IP: " + defaultMsg));
          }
        });

    controlPoint.execute(
        new GetStatusInfo(service) {
          @Override
          protected void success(final Connection.StatusInfo statusInfo) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    view.setStatusInfo(statusInfo);
                  }
                });
          }

          @Override
          public void failure(
              ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            Workbench.log(
                new LogMessage(
                    Level.INFO,
                    "WANIPConnection ControlPoint",
                    "Can't retrieve connection status: " + defaultMsg));
          }
        });
  }