Package com.cedarsoft.spring.rcp.commands

Source Code of com.cedarsoft.spring.rcp.commands.AbstractBackgroundCommand

package com.cedarsoft.spring.rcp.commands;

import com.cedarsoft.spring.rcp.async.BackgroundAction;
import com.cedarsoft.spring.rcp.async.BlockingBackgroundActionRunner;
import com.cedarsoft.CanceledException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

/**
* //todo remove vererbung
*/
@Deprecated
public abstract class AbstractBackgroundCommand extends ExtendedCommand {
  private BlockingBackgroundActionRunner actionRunner;

  protected AbstractBackgroundCommand( @NotNull @NonNls String commandId ) {
    super( commandId );
  }

  @Override
  protected void executeCommand() throws Exception {
    BackgroundAction action = new BackgroundAction( getId() + ".message" ) {
      @Override
      protected void prepare() throws CanceledException {
        AbstractBackgroundCommand.this.prepare();
      }

      @Override
      protected void executeInBackground() throws Exception {
        AbstractBackgroundCommand.this.executeInBackground();
      }

      @Override
      protected boolean confirm() {
        return AbstractBackgroundCommand.this.confirm();
      }
    };
    actionRunner = new BlockingBackgroundActionRunner( getApplicationWindow(), action, false );

    actionRunner.run();
  }

  public void setProgressMessage( @NotNull @NonNls String key, @NotNull Object... objects ) {
    if ( actionRunner != null ) {
      actionRunner.setProgressMessage( key, objects );
    }
  }

  protected abstract void prepare() throws CanceledException;

  protected abstract void executeInBackground() throws Exception;

  protected abstract boolean confirm();
}
TOP

Related Classes of com.cedarsoft.spring.rcp.commands.AbstractBackgroundCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.