Example #1
0
  /* (non-Javadoc)
   * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
   */
  @Override
  public void execute(
      IStepContext context,
      IPropertiesContainer data,
      IFullQualifiedId fullQualifiedId,
      IProgressMonitor monitor,
      final ICallback callback) {
    IPeerNode peerNode = getActivePeerModelContext(context, data, fullQualifiedId);
    if (peerNode != null) {
      IRuntimeModel model = ModelManager.getRuntimeModel(peerNode);
      final IModelChannelService service =
          model != null ? model.getService(IModelChannelService.class) : null;
      if (service != null) {
        Runnable runnable =
            new Runnable() {
              @Override
              public void run() {
                service.openChannel(
                    new IModelChannelService.DoneOpenChannel() {
                      @Override
                      public void doneOpenChannel(Throwable error, IChannel channel) {
                        callback.done(InitializeModelStep.this, StatusHelper.getStatus(error));
                      }
                    });
              }
            };

        Protocol.invokeLater(runnable);
      } else {
        callback.done(InitializeModelStep.this, Status.OK_STATUS);
      }
    } else {
      callback.done(InitializeModelStep.this, Status.OK_STATUS);
    }
  }
Example #2
0
  /**
   * Invoke the callback with the given parameters. If the given status severity is {@link
   * IStatus#ERROR}, the process launcher object is disposed automatically.
   *
   * @param status The status. Must not be <code>null</code>.
   * @param result The result object or <code>null</code>.
   */
  protected void invokeCallback(IStatus status, Object result) {
    // Dispose the process launcher if we report an error
    if (status.getSeverity() == IStatus.ERROR) {
      dispose();
    }

    // Invoke the callback
    ICallback callback = getCallback();
    if (callback != null) {
      callback.setResult(result);
      callback.done(this, status);
    }
  }