예제 #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
 @Override
 public void onCancel() {
   view.setCancelEnabled(false);
   if (actionExecutionFuture != null) {
     Workbench.Log.ACTION_INVOCATION.info("Interrupting action execution: " + action.getName());
     actionExecutionFuture.cancel(true);
   }
 }