Skip to content

Commit

Permalink
Implement ServiceHelper.loadFurnaceAndRun()
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-wyluda committed May 26, 2014
1 parent 97f9159 commit 63d4b09
Showing 1 changed file with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import org.jboss.forge.furnace.Furnace;

import java.util.concurrent.Future;

/**
* IntelliJ service utilities.
Expand Down Expand Up @@ -36,26 +41,35 @@ public static void loadFurnaceAndRun(Runnable callback)
}
else
{
getForgeService().startAsync();
startForgeInitTask();
runAfterFurnaceLoaded(callback);
Future<Furnace> future = getForgeService().startAsync();
startForgeInitTask(future, callback);
}
}

/**
* Starts Forge initiation background task.
*/
private static void startForgeInitTask()
private static void startForgeInitTask(final Future<Furnace> future, final Runnable callback)
{
// TODO Implement startForgeInitTask()
}
new Task.Backgroundable(null, "Starting Forge", true)
{
public void run(ProgressIndicator indicator)
{
indicator.setText("Loading Furnace");
indicator.setFraction(0.0);
try
{
future.get();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
indicator.setFraction(1.0);

/**
* Binds given action to Furnace lifecycle.
*/
private static void runAfterFurnaceLoaded(Runnable callback)
{
// TODO Implement runAfterFurnaceLoaded()
runOnUIThread(callback);
}
}.setCancelText("Stop loading").queue();
}

/**
Expand Down

0 comments on commit 63d4b09

Please sign in to comment.