Skip to content

Commit

Permalink
Create the "Gists" project when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalv committed Mar 6, 2012
1 parent 8580cf5 commit 94f5094
Showing 1 changed file with 23 additions and 0 deletions.
Expand Up @@ -29,9 +29,13 @@

import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
Expand All @@ -54,10 +58,29 @@ private class GistFile {

public void download(int gist, IReturner<IFile> returner, IProgressMonitor monitor)
throws BioclipseException {

if (monitor == null) {
monitor = new NullProgressMonitor();
}

SubMonitor subMonitor = SubMonitor.convert(monitor);
subMonitor.beginTask( "Downloading Gist", 100 );

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(GIST_PROJECT);
try {
if ( !project.exists() ) {
project.create(subMonitor.newChild(10));
}
project.open(subMonitor.newChild(10));
}
catch ( CoreException e ) {
throw new RuntimeException(
"Failed to prepare the Gists project",

This comment has been minimized.

Copy link
@egonw

egonw Mar 6, 2012

Member

Why not a BioclipseException? Can you explain that in a blog post, please?

This comment has been minimized.

Copy link
@jonalv
e );
}

monitor = subMonitor.newChild( 80 );
monitor.beginTask("Downloading Gist...", 2);

try {
Expand Down

0 comments on commit 94f5094

Please sign in to comment.